In a JavaFX 11 key event handler, when I check the event's key code, how can I check logically for the colon character, no matter which key combination on whatever keyboard layout means a colon? My application must respond to certain characters being input on the keyboard, where a colon means a certain command.
When I type colon (Shift+semicolon on the U.S. keyboard), the key code is not KeyCode.COLON
but rather KeyCode.SEMICOLON
with the modifier shift: true
. This is the case for both KeyPressed
and KeyTyped
.
I want my listener to check for the resulting character, not the particular key combination that produced that character. Otherwise, my listener may fail on other keyboard layouts besides U.S.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…