public class Keyboard extends EventGenerator
KEY_DOWN
and KEY_UP
and the high-level event TEXT_INPUT
. The low-level events may be
turned on, as they are off by default.Pressing the Q key on a PC/AT US keyboard using a US keyboard layout mapping will produce:
KEY_DOWN
with Q as letterTEXT_INPUT
with q as letterKEY_UP
with Q as letterKEY_DOWN
with SHIFT as letterKEY_DOWN
with Q as letterTEXT_INPUT
with Q as letterKEY_UP
with SHIFT as letterKEY_UP
with Q as letterModifier and Type | Field and Description |
---|---|
static int |
KEY_DOWN
The KEY_DOWN event action.
|
static int |
KEY_UP
The KEY_UP event action.
|
static int |
TEXT_INPUT
The TEXT_INPUT event action.
|
Constructor and Description |
---|
Keyboard(int bufferSize)
Keyboards hold a buffer (potentially of size one) that stores the keys before they are used by the application
(key associated to
KEY_UP , KEY_DOWN and TEXT_INPUT event). |
Modifier and Type | Method and Description |
---|---|
boolean |
dropOnFull()
Subclasses should override this method to specify their policy.
|
int |
getAction(int event)
Returns the keyboard action held by the keyboard event.
|
int |
getEventType()
Gets the event type associated with the event generator
|
char |
getNextChar(int event)
Gets the next character associated with the specified event.
|
void |
onlyTextInput(boolean onlyText)
|
void |
reset()
Reset the keyboard by flushing all pending characters.
|
void |
send(int type,
char c)
Send an keyboard event to the MicroUI application.
|
addToSystemPool, get, get, get, getEventHandler, getID, getList, removeFromSystemPool, sendEvent, setEventHandler
public static final int TEXT_INPUT
getAction(int)
,
Constant Field Valuespublic static final int KEY_DOWN
getAction(int)
,
Constant Field Valuespublic static final int KEY_UP
getAction(int)
,
Constant Field Valuespublic Keyboard(int bufferSize)
KEY_UP
, KEY_DOWN
and TEXT_INPUT
event). By default, a keyboard will
only send TEXT_INPUT
events.bufferSize
- the size of the buffer.dropOnFull()
,
onlyTextInput(boolean)
public boolean dropOnFull()
false
, which means the oldest data are overwritten by new data. If it returns true
new data are dropped
when the pump is full.true
to drop the new data or false
to overwrite the oldest data.public int getEventType()
EventGenerator
getEventType
in class EventGenerator
Event.KEYBOARD
public void onlyTextInput(boolean onlyText)
KEY_UP
and KEY_DOWN
events should be generated. By default they are not
generated.onlyText
- When true, the low level KEY_UP
and KEY_DOWN
are not issued to listener, only
TEXT_INPUT
events are sent.public int getAction(int event)
event
- the keyboard event.public char getNextChar(int event)
event
- an event in the standard MicroUI formatpublic void reset()
getNextChar(int)
public void send(int type, char c)
KEY_UP
, KEY_DOWN
and
TEXT_INPUT
.type
- a type between KEY_UP
, KEY_DOWN
and TEXT_INPUT
.c
- the character to send.