J2's Development notes-keyboard response
Different models have different responses to Keyboard Events. After my tests, Nokia and can only accept one key at a time. (I wrote a test program and found that if a key is not released after being pressed, The KeyPressed event will not be generated again, that is, the pressing operation of other keys is invalid, when using a buffer to control the sprite movement, if specified, only four directions can be moved. If up is pressed and left is pressed, the movement direction of the genie does not change. However, the key is buffered. Press "up", Press "left", and release "up". The Wizard moves to the left. (The left KeyPressed event is generated after the up is released! Strange? After the group is released, I did not perform the "Press" left action. The left key was pressed before the group was released and not released. It seems that the machine has been monitoring the states of keys on the keyboard, and there is a waiting queue .)
It is different in the standard simulator of wtk. It can accept events where multiple buttons are pressed at the same time. Therefore, if you use four parallel if operations, the genie can be skewed. If else is used for processing, if you have already pressed the next direction key and then pressed the other key, whether the direction can be changed is affected by the order in the if else statement. That is, if it is if (up) else if (left), The up key is checked first. Therefore, if you have pressed left and then pressed up, you can move up, in turn, it won't work. (This is natural :)
I have never tried other models because I have no machines at hand. So should we.