c# - Program doesn't capture the key -


as title , program have problem. made function(a battle function, player writes in textbox , press button). after battle done, program doesn't capture pressed keys, unless alt-tab , alt-tab again in program. have ?

//capture key function      private void joc_keydown_1(object sender, keyeventargs e) {      if (e.keycode == keys.f4 && e.alt && permite_pasi == true)     {         enableclose = false;     }      if (e.keycode == keys.d || e.keycode == keys.right && permite_pasi == true)     {         step(6); //step() movement function     }      if (e.keycode == keys.w || e.keycode == keys.up && permite_pasi == true)     {         step(8);     }      if (e.keycode == keys.a || e.keycode == keys.left && permite_pasi == true)     {         step(4);     }      if (e.keycode == keys.s || e.keycode == keys.down && permite_pasi == true)     {         step(2);     } }  //movement function public void step(int directie) {     if (directie == 6 && checkstep(directie) == true) { //checkstep() function check environment obstacles         if (check_npc(jucator.x, jucator.y) > 0) // function checking environment         {             scorenpc = check_npc(jucator.x, jucator.y); //some variabile             npc(check_npc(jucator.x, jucator.y), jucator.score); // battle function         }         else         {             //movement instructions         }     }     if (directie == 4 && checkstep(directie) == true)     {         if (check_npc(jucator.x, jucator.y) != 0)         {             scorenpc = check_npc(jucator.x, jucator.y);             npc(check_npc(jucator.x, jucator.y), jucator.score);         }         else         {             //movement instructions         }     }     if (directie == 8 && checkstep(directie) == true)     {         if (check_npc(jucator.x, jucator.y) > 0)         {             scorenpc = check_npc(jucator.x, jucator.y);             npc(check_npc(jucator.x, jucator.y), jucator.score);         }         else         {             //movement instructions         }     }     if (directie == 2 && checkstep(directie) == true)     {         if (check_npc(jucator.x, jucator.y) != 0)         {             scorenpc = check_npc(jucator.x, jucator.y);             npc(check_npc(jucator.x, jucator.y), jucator.score);         }         else         {             //movement instructions         }     } } 

i'll put rest of code in next edit if neccesary.

at ending of battle function, use this.focus().


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -