jcontrol.io
Class Keyboard
java.lang.Object
jcontrol.io.Keyboard
public class Keyboard
- extends Object
Accesses JControls keyboard.
There are two access modes:
- raw access directly reads the keyboard hardware at the time of the
method call, use this for polling user reactions.
- buffered access indrictly reads the keyboard via buffer, this mode polls
the keyboard in the background automatically and enables automatic keyboard repetition
and optional beep on keypress, use this mode for user interfaces and sporadic queries.
You can affect beep behaviour using the
buzzer.keyboardbeep
property
There are device dependent default keyboard to ASCII maps defined, you can change these at
runtime using the second constructor.
Device | Sticker | PCWatch | Stamp |
Layout | | | |
Map | {'S','u','U','d','D'} |
{'U','D','L','R','S'} | {'S'} |
- Author:
- Marcus Timmermann, Andreas Wesseler, Helge Böhme
- Available on JControl Devices:
Constructor Summary |
Keyboard()
Default keyboard initialisation, uses the hard-wired JControl keyboard. |
Keyboard(char[] keymap)
Keyboard initialisation, assigns a custom keymap to this Keyboard . |
Method Summary |
char |
getKey()
Buffered keyboard readout. |
char |
getRaw()
Raw keyboard readout. |
char |
read()
Default method for reading the keyboard. |
Keyboard
public Keyboard()
- Default keyboard initialisation, uses the hard-wired JControl keyboard.
As there is currently only one keyboard supported per device only one instance
is allowed.
Keyboard
public Keyboard(char[] keymap)
- Keyboard initialisation, assigns a custom keymap to this
Keyboard
.
As there is currently only one keyboard supported per device only one instance
is allowed.
- Parameters:
keymap
- array of characters containing all key labels; set to null
for default keymap
getKey
public char getKey()
- Buffered keyboard readout.
Disables wait for keypress (this method does not block), enables automatic key repetition
and keyboard beep (optional).
- Returns:
- the
char
of the pressed key or 0
if no key is pressed - See Also:
read()
,
getRaw()
getRaw
public char getRaw()
- Raw keyboard readout.
Disables wait for keypress (this method does not block), automatic key repetition
and keyboard beep.
- Returns:
- the
char
of the currently pressed key or 0
if no key is pressed
read
public char read()
- Default method for reading the keyboard.
Buffered keyboard readout, enables wait for keypress (this method blocks until
keypress), automatic key repetition and keyboard beep (optional).
- Returns:
- the
char
of the pressed key - See Also:
#get()
,
getRaw()