There seems to be a bug with keyboard handling in all version of the JDK
for linux with respect to KeyEvents.  The following small java program
demonstrates the problem.  Basically, when a key is pressed, and held down
multiple keyPressed/keyReleased events are generated, when only a
keyPressed event should be.  THe keyReleased event shouldn't occur
until the key is released.  This works correctly under both Sun's
and Microsoft's java implementation for windows.

To use the program, just click inside the Frame and hold down a key, 
you'll see keyReleased events generated.

import java.awt.*;
import java.awt.event.*;

public class KeyRepeatTest extends Frame
{
   public KeyRepeatTest()
   {
     super( "KeyRepeatTest" );
     
     addKeyListener( new KeyAdapter()
     {
       public void keyPressed( KeyEvent event )
       {
          System.out.println( "Key Pressed" );
       }
     
       public void keyReleased( KeyEvent event )
       {
         System.out.println( "Key Released" );
       }
     });

     requestFocus();
     setSize( 200, 200 );
     setVisible( true );
  }

  public static void main( String args[] )
  {
    new KeyRepeatTest();
  }
}

Cheers,

     Adam   

Reply via email to