Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 reads the keyboard hardware directly at time of method call. This mode can be used e.g. to poll user actions entered by the keyboard. Automatic key repetition and beep on keypress are not supported.
- buffered access reads the keyboard via an internal buffer (indirect read). Using this mode, the keyboard is polled automatically by a background task. Automatic key repetition and optional beep on keypress are supported. This mode can be used e.g. for graphical user interfaces or sporadic keyboard 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 |
| '`U`' |
|  | '`u`'
'`S`' |  |
|  | '`d`'
| '`D`' |
| '`U`' |
'`L`' | '`S`' | '`R`'
| '`D`' |
'`S`'
Map | `{'S','u','U','d','D'}` | `{'U','D','L','R','S'}` | `{'S'}`

Author:
  Marcus Timmermann, Andreas Wesseler, Helge Böhme
Available on JControl Devices:

  all

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.

Methods inherited from class java.lang.Object
`clone, equals, notifyAll, wait`

Constructor Detail

### 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

Method Detail

### 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()`

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD