JDK-4153069 : keyReleased behaviour incorrect
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.6,1.4.1
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux,solaris_2.5.1
  • CPU: x86,sparc
  • Submitted: 1998-06-29
  • Updated: 2008-09-17
Related Reports
Duplicate :  
Relates :  
Name: mf23781			Date: 06/29/98

The Event tests in the JCK:


fail on Solaris due to the fact that keyReleased implements 
incorrect behaviour. On Solaris the keyReleased event occurs 
after about half a second regardless of whether the key has 
been released or not. This is not a problem on NT as everything
works as designed.

The test case below shows this.

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class testkey extends Frame

   public void init( ){
      checkKey check = new checkKey();
      setSize( 300, 300 );
      setLayout(new GridLayout(0,1));
      TextField message = new TextField( "Hello Sailor" );
      message.addKeyListener( check );
      add( message );
   public static void main( String args[] )
      testkey test = new testkey();
      test.init( );
      test.show( );
   void testkey( )

class checkKey implements KeyListener
   public int KeyHits = 0;
   public void keyTyped( java.awt.event.KeyEvent e ) {
//    System.out.println( e );
   public void keyPressed( java.awt.event.KeyEvent e ) {
//    System.out.println( e );
   public void keyReleased( java.awt.event.KeyEvent e ) {
      System.out.println( e );

Uncomment the System.out  lines and another possible problem
can be seen. keyPressed and keyTyped events are generated for
each auto repeat if the key is held down. Is this behaving as 
###@###.### 10/5/04 07:42 GMT

EVALUATION will be filed by ###@###.### Name: rpR10076 Date: 02/12/2002 This bug doesn't meet Hopper criteria. It will be fixed in Mantis. ====================================================================== It appears that the problem is somewhat more complicated than I expected. Key released events come from native level, and I see no way to tell the events that arrive even if the key is pressed from the events that arrive if you actually release a key. I'll commit the bug to tiger in case a solution can be found. ###@###.### 2002-07-12 It may not be desirable to fix this: most people will want Java applications to act the same as other applications on their system. See 4274879 and 4701055. If we do try to fix the problem, we will need to have both behaviors supported for backwards compatibility. ###@###.### 2003-03-27