I have an application with a lot of screens (followed by MVC pattern), and I want to be able to receive in a fashion way the information that last key was pressed x seconds ago (120 sec let's say). Is there standard way to do this or I have to start a timer and every time when I pressed a key I have to override a variable and in the timer I have to check the difference time between that time and current time?
相关问题
- Unexpected JDWP Error 21
- Receive text message using J2ME
- How to detect key pressed event in LWUIT form?
- Are all Java SE classes available in Java ME?
- (J2ME) How to get list of files/resources inside m
Yes, just record the system timer when a key is pressed.
When a key is pressed again, you need to check the time difference to see how long it's been idle for.
If you need to trigger things without keypresses, then you need to start a thread which wakes now and again to check the elapsed time, and trigger an event of some kind when the time period has elapsed.