JDK-4850137 : numpad-5 key should produce keypressed/keyreleased even when numlock off
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,solaris_9
  • CPU: x86,sparc
  • Submitted: 2003-04-17
  • Updated: 2017-05-16
  • Resolved: 2003-07-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description
Pressing and releasing the numpad-5 key produces X-events when the numlock 
is off, but does not produce keypressed/keyreleased Java events.  We ought to 
give some indication that a key has been pressed/released.  However, we should 
not produce a keytyped event unless a unicode character is generated.  

Here is the result of running xev on a sparc (Solaris 9 update 2) 
KeyPress event, serial 23, synthetic NO, window 0x1680001,
    root 0x31, subw 0x0, time 2576694049, (163,460), root:(475,532),
    state 0x0, keycode 99 (keysym 0xffdc, F31), same_screen YES,
    XLookupString gives 0 characters:  ""

KeyRelease event, serial 23, synthetic NO, window 0x1680001,
    root 0x31, subw 0x0, time 2576694147, (163,460), root:(475,532),
    state 0x0, keycode 99 (keysym 0xffdc, F31), same_screen YES,
    XLookupString gives 0 characters:  ""

A synonym for XK_F31 is XK_R11 which doesn't help much.   
keysymdef.h says: 
#define XK_F31                  0xFFDC
#define XK_R11                  0xFFDC

Here is a section of my xmodmap: 
keycode  74 = Multi_key
keycode  75 = F27 F27 KP_7 Home
keycode  76 = Up F28 KP_8
keycode  77 = F29 F29 KP_9 Prior
keycode  78 = F24 F24 KP_Subtract
keycode  79 = F17 F17 SunOpen
keycode  80 = F18 F18 SunPaste
keycode  81 = End
keycode  82 =
...
keycode  96 = Return
keycode  97 = KP_Enter
keycode  98 = Left F30 KP_4
keycode  99 = F31 F31 KP_5
keycode 100 = Right F32 KP_6
keycode 101 = KP_Insert KP_Insert KP_0
keycode 102 = F19 F19 Find
keycode 103 = Prior

Interestingly, my Linux xmodmap says: 
keycode  83 = KP_Left KP_4
keycode  84 = KP_Begin KP_5
keycode  85 = KP_Right KP_6

keysymdef.h 
#define XK_KP_Page_Down         0xFF9B
#define XK_KP_End               0xFF9C
#define XK_KP_Begin             0xFF9D
#define XK_KP_Insert            0xFF9E
#define XK_KP_Delete            0xFF9F 

#define XK_Prior                0xFF55  /* Prior, previous */
#define XK_Page_Up              0xFF55
#define XK_Next                 0xFF56  /* Next */
#define XK_Page_Down            0xFF56
#define XK_End                  0xFF57  /* EOL */
#define XK_Begin                0xFF58  /* BOL */

Note that on Solaris, the numpad /*- keys produce F24, F25, F26, but in 
Java we map them to /*- anyway.  dtterm acts similar to Java.  dtterm also 
produces a 5 when the numpad 5 key is pressed, but numlock is off (F31).  
However, some applications, e.g. bugtraq, do not produce /*-5 when numlock 
is off.  StarOffice accepts - but not /* .



Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b11
2004-06-14

SUGGESTED FIX echawkes@gradgrind:/net/jano/export/disk26/awt/echawkes/jdk15-7/src/share/classes/sun/awt/resources( 229 )% sccs diffs -C awt.properties ------- awt.properties ------- *** /tmp/sccs.jeaWCN Tue Jun 3 18:28:39 2003 --- awt.properties Sun Jun 1 14:14:10 2003 *************** *** 29,34 **** --- 29,35 ---- AWT.up=Up AWT.right=Right AWT.down=Down + AWT.begin=Begin AWT.comma=Comma AWT.period=Period AWT.slash=Slash echawkes@gradgrind:/net/jano/export/disk26/awt/echawkes/jdk15-7/src/solaris/native/sun/awt( 225 )% !! sccs diffs -C canvas.c ------- canvas.c ------- *** /tmp/sccs.E_aqBN Tue Jun 3 18:25:10 2003 --- canvas.c Sun Jun 1 14:23:14 2003 *************** *** 269,274 **** --- 269,278 ---- {java_awt_event_KeyEvent_VK_RIGHT, osfXK_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, {java_awt_event_KeyEvent_VK_DOWN, osfXK_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, + /* Remaining Cursor control & motion */ + {java_awt_event_KeyEvent_VK_BEGIN, XK_Begin, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, + {java_awt_event_KeyEvent_VK_BEGIN, XK_KP_Begin, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD}, + {java_awt_event_KeyEvent_VK_0, XK_0, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, {java_awt_event_KeyEvent_VK_1, XK_1, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, {java_awt_event_KeyEvent_VK_2, XK_2, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, *************** *** 1305,1310 **** --- 1309,1318 ---- *keysym = XK_Page_Down; event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym); break; + case XK_KP_Begin: + *keysym = XK_Begin; + event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym); + break; case XK_KP_Insert: *keysym = XK_Insert; event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym); echawkes@gradgrind:/net/jano/export/disk26/awt/echawkes/jdk15-7/src/share/classes/java/awt/event( 232 )% sccs diffs -C KeyEvent.java ------- KeyEvent.java ------- *** /tmp/sccs.ddaODN Tue Jun 3 18:29:08 2003 --- KeyEvent.java Sun Jun 1 14:11:48 2003 *************** *** 756,761 **** --- 756,767 ---- public static final int VK_ALT_GRAPH = 0xFF7E; /** + * Constant for the Begin key. + * @since 1.5 + */ + public static final int VK_BEGIN = 0xFF58; + + /** * This value is used to indicate that the keyCode is unknown. * KEY_TYPED events do not have a keyCode value; this value * is used instead. *************** *** 1100,1106 **** --- 1104,1118 ---- case VK_UP: return Toolkit.getProperty("AWT.up", "Up"); case VK_RIGHT: return Toolkit.getProperty("AWT.right", "Right"); case VK_DOWN: return Toolkit.getProperty("AWT.down", "Down"); + case VK_BEGIN: return Toolkit.getProperty("AWT.begin", "Begin"); *************** *** 1304,1309 **** --- 1312,1318 ---- case VK_DOWN: case VK_LEFT: case VK_RIGHT: + case VK_BEGIN: case VK_KP_LEFT: case VK_KP_UP: ###@###.### 2003-06-03
2003-06-03

EVALUATION Should try to do this. ###@###.### 2003-04-17 Note: on windows, VK_CLEAR is generated, so this is an x-windows issue. Adding a keycode for VK_BEGIN would cure the problem on Linux. This is a standard xmodmap, and has been the default on RH for years. ###@###.### 2003-04-20 I should be careful when I use "default" and "Linux" in the same sentence. I just tested on ###@###.###'s machine, and his default xmodmap (on RedHat 9 w/ Gnome/Metacity) has 0-9 as the only entry for his numpad keys. In other words, he can't cursor around using the numpad keys regardless of the state of the numlock. What a dumb xmodmap. ###@###.### 2003-06-03
2003-06-03