Android “back” button vs Desktop “Escape” key

老子叫甜甜 提交于 2019-11-28 14:27:37

JavaFXPorts already has support for the back button on Android: it is mapped to the Escape key.

You can also use Gluon Charm Down, an OSS project that will let you easily find out about the platform you are running.

public void start(Stage primaryStage) {
    Scene = new Scene(...);

    scene.addEventHandler(KeyEvent.KEY_RELEASED, e -> {
        if (KeyCode.ESCAPE.equals(e.getCode())) {
            if (JavaFXPlatform.isAndroid()) {
                // bring up the menu or other Android stuff
            } else {
                // bring up the menu or other Desktop stuff
            }
        });
    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!