I'm designing a game calculator . My problem is how to link between the keyboard event and the button. **When I click no.2 button on my Keyboard the button doesn't roolover . I want the exact button roolover wen I use the keyboard .
Note
every button have it's instance name ex: the button of number one : one_mc
my code is
switch (event.keyCode)
{
case 97 :
res[1].appendText("1");
break;
case 98 :
res[1].appendText("2");
break;
case 99 :
res[1].appendText("3");
break;
case 100 :
res[1].appendText("4");
break;
case 101 :
res[1].appendText("5");
break;
case 102 :
res[1].appendText("6");
break;
case 103 :
res[1].appendText("7");
break;
case 104 :
res[1].appendText("8");
break;
case 105 :
res[1].appendText("9");
break;
case 96 :
res[1].appendText("0");
break;
case 8 :
res[1].replaceText(res[1].text.length-1,res[1].text.length,'');
break;
}
event.keyCode-96
... (don't forget to check the range, ofc) \$\endgroup\$case (int)'0'
orcase (int)'+'
which might help in readability. \$\endgroup\$