×

Discussion Board

Results 1 to 2 of 2

Thread: Key press delay

  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    USA, FL
    Posts
    148

    Key press delay

    I'm writing a game. My dev. environment is Sun Wireless Toolkit 1.04
    So, I use the emulators from there - everything is working perfectly. Now, I've downloaded an SDK for Nokia 7210 and a key problem appeared. When I press any key and release it instantly, I see on the phone emulator that key was pressed, but program could not receive this notification! When press a key and hold it a little bit, then program receives a multiple key press notifications. Is it a normal behaviour for this emulator and on real device everything should be OK? Or it is "feature"? and to avoid it???

    I get key notifications from my class which extends Canvas

    public class MyCanvas extends Canvas
    {
    ...
    protected void keyPressed(int keyCode)
    {
    int code = getGameAction(keyCode);
    System.out.println("pressed key:" + getKeyName(keyCode) + " code:" + code);
    m_game.KeyPressed(code);
    }

    protected void keyReleased(int keyCode)
    {
    int code = getGameAction(keyCode);
    m_game.KeyReleased(code);
    }

    protected void keyRepeated(int keyCode)
    {
    int code = getGameAction(keyCode);
    System.out.println("repeated key:" + getKeyName(keyCode));
    keyPressed(keyCode);
    }
    }

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    12

    RE: Key press delay

    I've noticed a delay between pressing keys and the keyPressed() method being triggered on the 7210 emulator. I've never seen it not trigger the method at all, which is what you seem to be indicating. I don't know if the delay is just a feature of the emulator, or of the phone as well -- I asked a similar question, look for the thread entitled "Key Polling" for more info. Anyway, the bottom line is that on any implementation there will always be a slight delay between you pressing a key and the keyPressed() method being called, due to threads etc. Whether this delay is noticeable to the user depends on the implementation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×