J2's Development notes-keyboard response

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.