@@ -109,17 +109,21 @@ public class InputDisplay implements EventHandler<InputEvent> {
109109 private static final String mouseItemClass = "mouse-item" ;
110110 private static final PseudoClass pseudoClassActive = PseudoClass .getPseudoClass ("active" );
111111
112- // Keys
112+ // Main modifier keys
113113 private static final Set <KeyCode > MODIFIER_KEYS = Set .of (
114114 KeyCode .SHIFT ,
115115 KeyCode .SHORTCUT ,
116116 KeyCode .COMMAND ,
117117 KeyCode .CONTROL ,
118118 KeyCode .ALT ,
119- KeyCode .ALT_GRAPH
119+ KeyCode .ALT_GRAPH ,
120+ KeyCode .WINDOWS
120121 );
121122
122- // Buttons
123+ // Keys that can be locked
124+ private static final Set <KeyCode > LOCKABLE_KEYS = Set .of (KeyCode .CAPS , KeyCode .NUM_LOCK );
125+
126+ // Buttons
123127 private final BooleanProperty primaryDown = new SimpleBooleanProperty (false );
124128 private final BooleanProperty secondaryDown = new SimpleBooleanProperty (false );
125129 private final BooleanProperty middleDown = new SimpleBooleanProperty (false );
@@ -594,11 +598,13 @@ public void handle(KeyEvent event) {
594598 logger .trace ("Skipping text input to {}" , event .getTarget ());
595599 return ;
596600 }
597-
601+ boolean isLockable = LOCKABLE_KEYS . contains ( code );
598602 boolean isModifier = MODIFIER_KEYS .contains (code );
599603 if (event .getEventType () == KeyEvent .KEY_PRESSED ) {
600- if (isModifier ) {
601- currentModifiers .add (code );
604+ if (isModifier || isLockable ) {
605+ if (!isLockable || Platform .isKeyLocked (code ).orElse (Boolean .FALSE )) {
606+ currentModifiers .add (code );
607+ }
602608 updateModifierText ();
603609 } else {
604610 // Inconveniently, we can't get a reliable text representation from the keycode
@@ -608,8 +614,10 @@ public void handle(KeyEvent event) {
608614 }
609615 removePending .remove (code );
610616 } else if (event .getEventType () == KeyEvent .KEY_RELEASED ) {
611- if (removePending .add (code )) {
612- Platform .runLater (this ::handleRemove );
617+ if (!isLockable || !Platform .isKeyLocked (code ).orElse (Boolean .FALSE )) {
618+ if (removePending .add (code )) {
619+ Platform .runLater (this ::handleRemove );
620+ }
613621 }
614622 }
615623
@@ -633,7 +641,7 @@ private void handleRemove() {
633641 private String getText (KeyEvent event ) {
634642 String text = event .getText ();
635643 if (event .getCode ().isLetterKey ())
636- return text .toUpperCase ();
644+ return event . getCode (). getName () .toUpperCase ();
637645 if (text .trim ().isEmpty ())
638646 return getText (event .getCode ());
639647 return text ;
@@ -673,6 +681,12 @@ private static String getSymbol(KeyCode code) {
673681 case TAB -> isMac ? "⇥" : "↹" ;
674682 case SPACE -> "␣" ;
675683 case ESCAPE -> "Esc" ;
684+ case WINDOWS -> "Win" ;
685+ case CAPS -> "⇪" ;
686+ case HOME -> "⇱" ;
687+ case END -> "⇲" ;
688+ case PAGE_UP -> "⇞" ;
689+ case PAGE_DOWN -> "⇟" ;
676690 default -> null ;
677691 };
678692 }
0 commit comments