JDK-8172104 : Dead keys are not detected
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u20,9
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows
  • CPU: x86_64
  • Submitted: 2016-12-28
  • Updated: 2017-03-10
  • Resolved: 2017-01-16
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 Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Description
FULL PRODUCT VERSION :
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux alcibiade 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
French AZERTY keyboard

A DESCRIPTION OF THE PROBLEM :
Dead key (ie. ^ or ��) are not detected with KeyEvent events. Therefore it's impossible to write characters like "^" or "��" or "��".

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Write a simple program which displays the key code (see source code), an hit:

- "^" ;
- "^" + "e".

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
- "^" : code=DEAD_CIRCUMFLEX; text=^
- "^" + "e" : code=UNDEFINED; text=��
ACTUAL -
- "^" : code=UNDEFINED; text=
- "^" + "e" : code=E; text=e

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package sample;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class Main extends Application {

	@Override
	public void start(Stage primaryStage) throws Exception {

		BorderPane pane = new BorderPane();
		Label pressed = new Label("Press a key...");
		pane.setLeft(pressed);
		Scene scene = new Scene(pane, 200, 50);
		primaryStage.setScene(scene);
		primaryStage.show();

		scene.addEventFilter(KeyEvent.KEY_PRESSED, e -> pressed.setText(
            "Key pressed:\ncode: " + e.getCode() + "\ntext: " + e.getText()));
	}

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

}
---------- END SOURCE ----------


Comments
Actual PRESS events behavior in 9 b153: - "^" : code=DEAD_CIRCUMFLEX; text=^ - "^" + "e" : code=E; text=e which looks correct because according to the spec: code: /** * The integer key code associated with the key in this key * pressed or key released event. * For key typed events, {@code code} is always {@code KeyCode.UNDEFINED}. */ for both key pressed events the values are correct: ^ = DEAD_CIRCUMFLEX(0x82, "Dead Circumflex") E = E(0x45, "E", KeyCodeClass.LETTER) text: /** * A String describing the key code, such as "HOME", "F1" or "A", * for key pressed and key released events. * For key typed events, {@code text} is always the empty string. */ both values are correct again: "^" describes 0x82 key "e" describes the letter case of E key "��" doesn't describe a single key pressed it describes a result of a sequence of keys. On Windows platform the character result may not be obtained on each WM_KEYDOWN event in the sqeuence. ::MultiByteToWideChar() called with MB_COMPOSITE flag on 2nd key press will break longer key sequences because during the compositing the keyboard buffer content is unrecoverably distorted. But according to the spec the resulting character should be send in the character property of the KeyEvent.KEY_TYPED event. The issue should be closed as not an issue.
16-01-2017

This is likely a window-toolkit (glass) or scenegraph bug, not a controls bug.
03-01-2017

Verified the issue against 8,8u11,8u20,8u45,8u112,8u122,9ea on Windows 7 and could reproduce the issue on 8u20 and onwards while pressing "SHIFT + Key". Up to 8u11 only getText() is printing the expected output but not getCode(). Steps to reproduce(javac): ************************** - Run the attached file(Main.java) with JDK. Result: ********* OS : Microsoft Windows 7 Professional 64 bit [Version 6.1.7601], Linux Ubuntu 14.04 LTS Keyboard type : QWERTY JDK(Windows 7): ++++++++++++++ 8 b132 : Pass [getCode()= Fail , getText()=Pass] 8u11 b12 : Pass [getCode()= Fail , getText()=Pass] 8u20 b26 : Fail [getCode()= Fail , getText()=Fail] 8u45 b14 : Fail [getCode()= Fail , getText()=Fail] 8u112 b15 : Fail [getCode()= Fail , getText()=Fail] 8u122ea b04 : Fail [getCode()= Fail , getText()=Fail] 9ea+148 : Fail [getCode()= Fail , getText()=Fail] JDK(Linux Ubuntu): ++++++++++ 8 b132 : Pass [getCode()= Fail , getText()=Pass] 8u112 b15 : Pass [getCode()= Fail , getText()=Pass] 8u122ea b04 : Pass [getCode()= Fail , getText()=Pass] 9ea+148 : Pass [getCode()= Fail , getText()=Pass] ================================================================
29-12-2016