is ESC key pressed JavaFX KeyEvent - Java JavaFX

Java examples for JavaFX:Key Event

Description

is ESC key pressed JavaFX KeyEvent

Demo Code


//package com.java2s;

import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

public class Main {
    public static boolean isESC(KeyEvent event) {
        boolean esc = event.getCode() == KeyCode.ESCAPE;
        if (!esc) {
            String str = event.getCharacter();
            if (!str.isEmpty()) {
                esc = str.charAt(0) == 27;
            }//  www.j  a v a  2 s.  co  m
        }
        return esc;
    }
}

Related Tutorials