Class KeyBind
java.lang.Object
megalodonte.base.v2.KeyBind
Keyboard shortcut binding utility. Registers key combinations (with optional
modifiers) and attaches them to a
Scene or Node.
Usage:
new KeyBind()
.on(KeyCode.DIGIT1, () -> showPopup("Shortcut SHIFT+1!"), KeyBind.Modifier.SHIFT)
.on(KeyCode.S, () -> save(), KeyBind.Modifier.CTRL)
.on(KeyCode.F5, () -> reload())
.attach(scene);
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattach(ScreenContextInterface screenContext) Attaches the key bindings to a screen context's key event filter.on(javafx.scene.input.KeyCode key, Runnable action, KeyBind.Modifier... modifiers) Registers a key combination with an action.
-
Constructor Details
-
KeyBind
public KeyBind()
-
-
Method Details
-
on
Registers a key combination with an action.- Parameters:
key- the key codeaction- the action to run when the combo is pressedmodifiers- optional modifiers (SHIFT, CTRL, ALT)- Returns:
- this instance for chaining
-
attach
Attaches the key bindings to a screen context's key event filter.
-