Doubts on KeyCode
Scott Palmer
swpalmer at gmail.com
Mon Mar 30 11:19:32 UTC 2015
If I recall correctly there is one keycode named PLUS and another named ADD. One of them refers to the numeric keypad.
Scott
> On Mar 30, 2015, at 6:58 AM, Tom Schindl <tom.schindl at bestsolution.at> wrote:
>
> hi,
>
> suppose you have the following code:
>
>> package application;
>>
>> import javafx.application.Application;
>> import javafx.scene.Scene;
>> import javafx.scene.control.TextField;
>> import javafx.scene.layout.BorderPane;
>> import javafx.stage.Stage;
>>
>> public class Main extends Application {
>> @Override
>> public void start(Stage primaryStage) {
>> try {
>> BorderPane root = new BorderPane();
>> Scene scene = new Scene(root, 400, 400);
>>
>> TextField f = new TextField();
>> f.setOnKeyReleased( e -> {
>> System.err.println(e.getCode());
>> });
>> root.setCenter(f);
>>
>> primaryStage.setScene(scene);
>> primaryStage.show();
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>>
>> public static void main(String[] args) {
>> launch(args);
>> }
>> }
>
> For default ASCII-Chars like a, b, c, ... I get the correct KeyCode but
> e.g. for +, -, ... the information is totally bogus. Please note I get
> the correct keyCode when pressing the NumPad char but e.g. CLOSE_BRACKET
> when pressing "+" on my keyboard.
>
> If I'm not completely mistaken the KeyCode defintion for the current +
> is the one for the keypad "+" and the one for the ordinary + is missing?
>
> This means that the definition:
>
> PLUS(0x0209, "Plus")
>
> has to be
>
> PLUS(0x0209, "Plus", KeyCodeClass.KEYPAD)
>
> What I can not explain is why the keyboard "+" (ascii-code 43) maps to
> "]" (ascii-code 93) from a native-keyevent to KeyCode happens in
> Glass-Layer.
>
> Tom
>
> --
> Thomas Schindl, CTO
> BestSolution.at EDV Systemhaus GmbH
> Eduard-Bodem-Gasse 5-7, A-6020 Innsbruck
> http://www.bestsolution.at/
> Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck
More information about the openjfx-dev
mailing list