-
Bug
-
Resolution: Fixed
-
P1
-
1.1.4
-
None
Using the following java program, you will see that no value is returned
for a method invocation of getKeyChar() when the KeyPad keys are used. Having
NumLock on or off does not seem to make any difference (although it should).
import java.applet.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
public class Key extends Applet
{
private KeyWatch keyear;
private Button but1;
private Button but2;
private TextArea fld;
public Key() {}
public void init()
{
keyear = new KeyWatch();
this.setLayout(new FlowLayout(FlowLayout.CENTER, 30, 30));
but1 = new Button("Press Me");
but2 = new Button("Hit Me");
fld = new TextArea("Some Text\nSome Text\nSome Text\nSome Text", 10, 20);
this.add(but1);
this.add(but2);
this.add(fld);
but1.addKeyListener(keyear);
but2.addKeyListener(keyear);
fld.addKeyListener(keyear);
this.addKeyListener(keyear);
}
}
class KeyWatch extends KeyAdapter
{
public void keyPressed(KeyEvent e)
{
System.out.print("KeyChar=" + e.getKeyChar());
System.out.print(" KeyCode=" + e.getKeyCode() );
System.out.println(" KeyText=" + e.getKeyText(e.getKeyCode()));
}
}
// end of code
So, with NumLock ON, as I press KeyPad keys 1-9 I get:
KeyChar= KeyCode=35 KeyText=End
KeyChar= KeyCode=40 KeyText=Down
KeyChar= KeyCode=34 KeyText=Page Down
KeyChar= KeyCode=37 KeyText=Left
KeyChar= KeyCode=39 KeyText=Right
KeyChar= KeyCode=36 KeyText=Home
KeyChar= KeyCode=38 KeyText=Up
KeyChar= KeyCode=33 KeyText=Page Up
And, with NumLock OFF, I get:
KeyChar= KeyCode=35 KeyText=End
KeyChar= KeyCode=40 KeyText=Down
KeyChar= KeyCode=34 KeyText=Page Down
KeyChar= KeyCode=37 KeyText=Left
KeyChar= KeyCode=39 KeyText=Right
KeyChar= KeyCode=36 KeyText=Home
KeyChar= KeyCode=38 KeyText=Up
KeyChar= KeyCode=33 KeyText=Page Up
I SHOULD GET:
with NumLock ON
KeyChar=1 KeyCode=97 KeyText=NumPad-1
KeyChar=2 KeyCode=98 KeyText=NumPad-2
KeyChar=3 KeyCode=99 KeyText=NumPad-3
KeyChar=4 KeyCode=100 KeyText=NumPad-4
KeyChar=5 KeyCode=101 KeyText=NumPad-5
KeyChar=6 KeyCode=102 KeyText=NumPad-6
KeyChar=7 KeyCode=103 KeyText=NumPad-7
KeyChar=8 KeyCode=104 KeyText=NumPad-8
KeyChar=9 KeyCode=105 KeyText=NumPad-9
with NumLock OFF
KeyChar= KeyCode=35 KeyText=End
KeyChar= KeyCode=225 KeyText=Down
KeyChar= KeyCode=34 KeyText=Page Down
KeyChar= KeyCode=226 KeyText=Left
KeyChar= KeyCode=227 KeyText=Right
KeyChar= KeyCode=36 KeyText=Home
KeyChar= KeyCode=224 KeyText=Up
KeyChar= KeyCode=33 KeyText=Page Up
for a method invocation of getKeyChar() when the KeyPad keys are used. Having
NumLock on or off does not seem to make any difference (although it should).
import java.applet.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
public class Key extends Applet
{
private KeyWatch keyear;
private Button but1;
private Button but2;
private TextArea fld;
public Key() {}
public void init()
{
keyear = new KeyWatch();
this.setLayout(new FlowLayout(FlowLayout.CENTER, 30, 30));
but1 = new Button("Press Me");
but2 = new Button("Hit Me");
fld = new TextArea("Some Text\nSome Text\nSome Text\nSome Text", 10, 20);
this.add(but1);
this.add(but2);
this.add(fld);
but1.addKeyListener(keyear);
but2.addKeyListener(keyear);
fld.addKeyListener(keyear);
this.addKeyListener(keyear);
}
}
class KeyWatch extends KeyAdapter
{
public void keyPressed(KeyEvent e)
{
System.out.print("KeyChar=" + e.getKeyChar());
System.out.print(" KeyCode=" + e.getKeyCode() );
System.out.println(" KeyText=" + e.getKeyText(e.getKeyCode()));
}
}
// end of code
So, with NumLock ON, as I press KeyPad keys 1-9 I get:
KeyChar= KeyCode=35 KeyText=End
KeyChar= KeyCode=40 KeyText=Down
KeyChar= KeyCode=34 KeyText=Page Down
KeyChar= KeyCode=37 KeyText=Left
KeyChar= KeyCode=39 KeyText=Right
KeyChar= KeyCode=36 KeyText=Home
KeyChar= KeyCode=38 KeyText=Up
KeyChar= KeyCode=33 KeyText=Page Up
And, with NumLock OFF, I get:
KeyChar= KeyCode=35 KeyText=End
KeyChar= KeyCode=40 KeyText=Down
KeyChar= KeyCode=34 KeyText=Page Down
KeyChar= KeyCode=37 KeyText=Left
KeyChar= KeyCode=39 KeyText=Right
KeyChar= KeyCode=36 KeyText=Home
KeyChar= KeyCode=38 KeyText=Up
KeyChar= KeyCode=33 KeyText=Page Up
I SHOULD GET:
with NumLock ON
KeyChar=1 KeyCode=97 KeyText=NumPad-1
KeyChar=2 KeyCode=98 KeyText=NumPad-2
KeyChar=3 KeyCode=99 KeyText=NumPad-3
KeyChar=4 KeyCode=100 KeyText=NumPad-4
KeyChar=5 KeyCode=101 KeyText=NumPad-5
KeyChar=6 KeyCode=102 KeyText=NumPad-6
KeyChar=7 KeyCode=103 KeyText=NumPad-7
KeyChar=8 KeyCode=104 KeyText=NumPad-8
KeyChar=9 KeyCode=105 KeyText=NumPad-9
with NumLock OFF
KeyChar= KeyCode=35 KeyText=End
KeyChar= KeyCode=225 KeyText=Down
KeyChar= KeyCode=34 KeyText=Page Down
KeyChar= KeyCode=226 KeyText=Left
KeyChar= KeyCode=227 KeyText=Right
KeyChar= KeyCode=36 KeyText=Home
KeyChar= KeyCode=224 KeyText=Up
KeyChar= KeyCode=33 KeyText=Page Up
- relates to
-
JDK-4095064 Using JDK 1.1.5, arrow keys don't function properly if NumLock On
-
- Closed
-
-
JDK-4041942 Arrow keys don't function properly in TextField if num. lock set.
-
- Closed
-