public class WinKeyboardReader extends SwingKeyboardReader
SwingKeyboardReader
implementation for clients which require
Windows compatibility.keyDownEvents, queue, xlate
Constructor and Description |
---|
WinKeyboardReader()
Default c'tor.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
ctrlTyped(int key)
Returns
true if, for the given key, a keyTyped(java.awt.event.KeyEvent) event is also raised,
beside a keyPressed(java.awt.event.KeyEvent) , when used in conjunction with the Control key. |
void |
keyPressed(java.awt.event.KeyEvent evt)
This method is called when any key is pressed or when a multi-key combination (CTRL, SHIFT,
ALT modifiers) is pressed.
|
void |
keyReleased(java.awt.event.KeyEvent evt)
Invoked when a key has been released.
|
void |
keyTyped(java.awt.event.KeyEvent evt)
This method is called when a pressed key (or a multi-key combination) is converted to a
higher level representation.
|
private int |
processAlt(int code)
Process the given key by setting the 10th bit.
|
private int |
processShift(int code)
Process the given key by setting the 9th bit.
|
findKeyEventByKeyCode, insert, isModifier, isSpecialCharacter, mergeWithLastEvent, read
public WinKeyboardReader()
public void keyPressed(java.awt.event.KeyEvent evt)
keyTyped(java.awt.event.KeyEvent)
, with an exception: if
CTRL is pressed with a latin character, then the processing is deferred to keyTyped(java.awt.event.KeyEvent)
;
otherwise, if CTRL is pressed, bit 11 (CTRL modifier) is set and the key is sent to the
SwingKeyboardReader.queue
, in FIFO order.
All other ALT processing is deferred to the keyTyped(java.awt.event.KeyEvent)
method, with this exception:
if the 4GL key code is VK_TAB and the SHIFT modifier key is on (the shift key was pressed
at the time the tab was pressed), then a VK_BACKTAB is posted to the queue. Otherwise,
the VK_TAB is ignored because it is naturally processed in keyTyped(java.awt.event.KeyEvent)
(but the back
tab is not).
keyPressed
in interface java.awt.event.KeyListener
keyPressed
in class java.awt.event.KeyAdapter
evt
- The high level key event to process.public void keyTyped(java.awt.event.KeyEvent evt)
Once a valid key code is generated, that key code is added to the key input queue in FIFO order.
The non-visual values 0 through 31 are handled almost "for free". The user generates these in the following manner:
Key Code User Input Notes -------- ----------------------- -------------------------------------- 0 CTRL+2 Special code in this method supports this. 1 CTRL+A 2 CTRL+B 3 CTRL+C 4 CTRL+D 5 CTRL+E 6 CTRL+F 7 CTRL+G 8 CTRL+H or VK_BACKSPACE 9 CTRL+I or VK_TAB The containing frame's focus traversal keys must be forced to the empty set in order for this to work. 10 CTRL+J or VK_ENTER NOT DELIVERED, handled in keyPressed() 11 CTRL+K 12 CTRL+L 13 CTRL+M 14 CTRL+N 15 CTRL+O 16 CTRL+P 17 CTRL+Q 18 CTRL+R 19 CTRL+S 20 CTRL+T 21 CTRL+U 22 CTRL+V 23 CTRL+W 24 CTRL+X 25 CTRL+Y 26 CTRL+Z 27 VK_ESCAPE DELIVERED; Windows mode allows this. 28 CTRL+\ 29 CTRL+] 30 CTRL+6 Special code in this method supports this. 31 CTRL+- Special code in this method supports this.
ALT key is the modifier which sets the key code's 10th bit. If this is determined to be
pressed together with the key, than bit 10 will be set and this key will be pushed to the
SwingKeyboardReader.queue
, but only if the key code's label is not the empty string.
keyTyped
in interface java.awt.event.KeyListener
keyTyped
in class java.awt.event.KeyAdapter
evt
- The high level key event to process.public void keyReleased(java.awt.event.KeyEvent evt)
keyReleased
in interface java.awt.event.KeyListener
keyReleased
in class SwingKeyboardReader
evt
- The key release event.private int processAlt(int code)
code
- The key code to be processed.-1
if the ALT-key combination has no label.private int processShift(int code)
code
- The key code to be processed.-1
if the SHIFT-key combination has no label.private boolean ctrlTyped(int key)
true
if, for the given key, a keyTyped(java.awt.event.KeyEvent)
event is also raised,
beside a keyPressed(java.awt.event.KeyEvent)
, when used in conjunction with the Control key.key
- The pressed key.true
if the CTRL-<key>
combination will be
treated by keyTyped(KeyEvent)
.