Example usage for javafx.scene.input KeyEvent getEventType

List of usage examples for javafx.scene.input KeyEvent getEventType

Introduction

In this page you can find the example usage for javafx.scene.input KeyEvent getEventType.

Prototype

@Override
    public EventType<KeyEvent> getEventType() 

Source Link

Usage

From source file:Main.java

public static java.awt.event.KeyEvent toAwt(final KeyEvent event) {
    final EventType type = event.getEventType();
    if (null == type) {
        return null;
    }//from  www . j  a v a 2  s . c om

    final int id;
    if (KeyEvent.KEY_TYPED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_TYPED;
    } else if (KeyEvent.KEY_PRESSED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_PRESSED;
    } else if (KeyEvent.KEY_RELEASED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_RELEASED;
    } else {
        return null;
    }

    final long when = -1;
    final int modifiers = modifiers(event);
    final int keyCode = keyCode(event);
    final String keyValue = event.getCharacter();
    final char keyChar = keyValue != null && !keyValue.isEmpty() ? keyValue.charAt(0) : ' ';
    return new java.awt.event.KeyEvent(empty, id, when, modifiers, keyCode, keyChar);
}