FULL PRODUCT VERSION :
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin machinename 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
EXTRA RELEVANT SYSTEM CONFIGURATION :
Using an Apple USB Keyboard with numeric keyboard Norwegian - like this one: http://www.apple.com/uk/shop/product/MB110H/B/apple-keyboard-with-numeric-keypad-norwegian
A DESCRIPTION OF THE PROBLEM :
The function keys F17, F18 and F19 return a keyCode value of "0" instead of the values described in https://docs.oracle.com/javase/7/docs/api/constant-values.html#java.awt.event.KeyEvent.VK_F17 through VK_F19. This makes it impossible to use these last three function keys on the keyboard in Java applications. F1 through F16 work as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I originally reported this as a bug in the Google Android Studio product. There is a simple test case attached here: https://code.google.com/p/android/issues/detail?id=184996#c2
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When pressing F12, F16, F17, F18, F19 the sample application should display:
F12: 123
F16: 61443
F17: 61444
F18: 61445
F19: 61446
ACTUAL -
When pressing F12, F16, F17, F18, F19 the sample application displays:
F12: 123
F16: 61443
Other key: 0
Other key: 0
Other key: 0
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Frame;
import java.awt.KeyboardFocusManager;
import java.awt.TextArea;
import java.awt.event.KeyEvent;
class Main extends Frame {
Main() {
TextArea textArea = new TextArea("Press A Key");
textArea.setBounds(30, 100, 200, 60);
add(textArea);
setSize(300, 300);
setLayout(null);
setVisible(true);
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(ke -> {
if (ke.getID() == KeyEvent.KEY_PRESSED) {
switch (ke.getKeyCode()) {
case KeyEvent.VK_F12:
textArea.setText("F12: " + ke.getKeyCode());
break;
case KeyEvent.VK_F16:
textArea.setText("F16: " + ke.getKeyCode());
break;
case KeyEvent.VK_F17:
textArea.setText("F17: " + ke.getKeyCode());
break;
case KeyEvent.VK_F18:
textArea.setText("F18: " + ke.getKeyCode());
break;
case KeyEvent.VK_F19:
textArea.setText("F19: " + ke.getKeyCode());
break;
default:
textArea.setText("Other key: " + ke.getKeyCode());
}
}
return false;
});
}
public static void main(String args[]) {
Main f = new Main();
}
}
---------- END SOURCE ----------