Skip to content

KeyboardFX

Jonato edited this page Feb 27, 2016 · 1 revision

KeyboardFX helps you to handle user keyboard events. It can be used for Nodes and Scenes. You can add or remove actions to keyboard shortcuts on the different levels. With the KeyboardRegistry you get a central place for saving you instances with a given name.

Sample for a Node

TextField textField = new TextField();
IKeyboard iKeyboard = KeyboardFactory.getKeyboardForNode(textField);
iKeyboard.addKeyStroke(new KeyStroke(KeyCode.ALT, KeyCode.F5), (e,f) -> System.out.println("PRESSED ALT + F5 on TEXTFIELD"));
iKeyboard.addKeyStroke(new KeyStroke(KeyCode.CONTROL, KeyCode.S), (e,f) -> System.out.println("PRESSED CTRL + S on TEXTFIELD"));

Sample for a Scene

IKeyboard SceneKeyboard = KeyboardFactory.getKeyboardForScene(scene, stage);
iKeyboard.addKeyStroke(new KeyStroke(KeyCode.ALT, KeyCode.F6), (e,f) -> System.out.println("PRESSED ALT + F6 on SCENE"));
iKeyboard.addKeyStroke(new KeyStroke(KeyCode.CONTROL, KeyCode.F3), (e,f) -> System.out.println("PRESSED CTRL + F3 on SCENE"));
Clone this wiki locally