|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme.input.Input
com.jme.input.KeyInput
public abstract class KeyInput
KeyInput
provides an interface for dealing with keyboard input.
There are public contstants for each key of the keyboard, which correspond
to the LWJGL key bindings. This may require conversion by other subclasses
for specific APIs.
The status of spcific keys can be queried via the isKeyDown(int)
method. For each key that is pressed or released an event is generated which
can be received by a KeyInputListener
, these are subsribed via
addListener(KeyInputListener)
. Handling of events is done inside the
update()
method.
Field Summary | |
---|---|
static java.lang.String |
INPUT_AWT
|
static java.lang.String |
INPUT_LWJGL
|
static int |
KEY_0
0 key. |
static int |
KEY_1
1 key. |
static int |
KEY_2
2 key. |
static int |
KEY_3
3 key. |
static int |
KEY_4
4 key. |
static int |
KEY_5
5 key. |
static int |
KEY_6
6 key. |
static int |
KEY_7
7 key. |
static int |
KEY_8
8 key. |
static int |
KEY_9
9 key. |
static int |
KEY_A
a key. |
static int |
KEY_ADD
+ key (num pad). |
static int |
KEY_APOSTROPHE
' key. |
static int |
KEY_APPS
|
static int |
KEY_AT
@ key (NEC PC98). |
static int |
KEY_AX
ax key (Japanese). |
static int |
KEY_B
b key. |
static int |
KEY_BACK
back key. |
static int |
KEY_BACKSLASH
\ key. |
static int |
KEY_C
c key. |
static int |
KEY_CAPITAL
caps lock key. |
static int |
KEY_CIRCUMFLEX
circum flex key (Japanese). |
static int |
KEY_COLON
: key (NEC PC98) |
static int |
KEY_COMMA
, key. |
static int |
KEY_CONVERT
convert key (Japanese). |
static int |
KEY_D
d key. |
static int |
KEY_DECIMAL
. |
static int |
KEY_DELETE
delete key. |
static int |
KEY_DIVIDE
/ key (num pad). |
static int |
KEY_DOWN
down arrow key. |
static int |
KEY_E
e key. |
static int |
KEY_END
end key. |
static int |
KEY_EQUALS
= key. |
static int |
KEY_ESCAPE
escape key. |
static int |
KEY_F
f key. |
static int |
KEY_F1
F1 key. |
static int |
KEY_F10
F10 key. |
static int |
KEY_F11
F11 key. |
static int |
KEY_F12
F12 key. |
static int |
KEY_F13
F13 key. |
static int |
KEY_F14
F14 key. |
static int |
KEY_F15
F15 key. |
static int |
KEY_F2
F2 key. |
static int |
KEY_F3
F3 key. |
static int |
KEY_F4
F4 key. |
static int |
KEY_F5
F5 key. |
static int |
KEY_F6
F6 key. |
static int |
KEY_F7
F7 key. |
static int |
KEY_F8
F8 key. |
static int |
KEY_F9
F9 key. |
static int |
KEY_G
g key. |
static int |
KEY_GRAVE
` key. |
static int |
KEY_H
h key. |
static int |
KEY_HOME
home key. |
static int |
KEY_I
i key. |
static int |
KEY_INSERT
insert key. |
static int |
KEY_J
j key. |
static int |
KEY_K
k key. |
static int |
KEY_KANA
kana key (Japanese). |
static int |
KEY_KANJI
kanji key (Japanese). |
static int |
KEY_L
l key. |
static int |
KEY_LBRACKET
[ key. |
static int |
KEY_LCONTROL
left control key. |
static int |
KEY_LEFT
left arrow key. |
static int |
KEY_LMENU
left alt key. |
static int |
KEY_LMETA
|
static int |
KEY_LSHIFT
left shift key. |
static int |
KEY_LWIN
The left windows key, mapped to KEY_LMETA |
static int |
KEY_M
m key. |
static int |
KEY_MINUS
- key. |
static int |
KEY_MULTIPLY
* key (on keypad). |
static int |
KEY_N
n key. |
static int |
KEY_NEXT
PgDn key. |
static int |
KEY_NOCONVERT
noconvert key (Japanese). |
static int |
KEY_NUMLOCK
NumLK key. |
static int |
KEY_NUMPAD0
0 key (num pad). |
static int |
KEY_NUMPAD1
1 key (num pad). |
static int |
KEY_NUMPAD2
2 key (num pad). |
static int |
KEY_NUMPAD3
3 key (num pad). |
static int |
KEY_NUMPAD4
4 key (num pad). |
static int |
KEY_NUMPAD5
5 key (num pad). |
static int |
KEY_NUMPAD6
6 key (num pad). |
static int |
KEY_NUMPAD7
7 key (num pad). |
static int |
KEY_NUMPAD8
8 key (num pad). |
static int |
KEY_NUMPAD9
9 key (num pad). |
static int |
KEY_NUMPADCOMMA
, key on num pad (NEC PC98). |
static int |
KEY_NUMPADENTER
Enter key (num pad). |
static int |
KEY_NUMPADEQUALS
= on num pad (NEC PC98). |
static int |
KEY_O
o key. |
static int |
KEY_P
p key. |
static int |
KEY_PAUSE
pause key. |
static int |
KEY_PERIOD
. |
static int |
KEY_PGDN
PgDn key. |
static int |
KEY_PGUP
PgUp key. |
static int |
KEY_POWER
power key. |
static int |
KEY_PRIOR
PgUp key. |
static int |
KEY_Q
q key. |
static int |
KEY_R
r key. |
static int |
KEY_RBRACKET
] key. |
static int |
KEY_RCONTROL
right control key. |
static int |
KEY_RETURN
enter (main keyboard) key. |
static int |
KEY_RIGHT
right arrow key. |
static int |
KEY_RMENU
right alt key. |
static int |
KEY_RMETA
|
static int |
KEY_RSHIFT
right shift key. |
static int |
KEY_RWIN
The right windows key, mapped to KEY_RMETA |
static int |
KEY_S
s key. |
static int |
KEY_SCROLL
Scroll lock key. |
static int |
KEY_SEMICOLON
; key. |
static int |
KEY_SLASH
/ key (main keyboard). |
static int |
KEY_SLEEP
sleep key. |
static int |
KEY_SPACE
space key. |
static int |
KEY_STOP
stop key (NEC PC98). |
static int |
KEY_SUBTRACT
- key (num pad). |
static int |
KEY_SYSRQ
SysRq key. |
static int |
KEY_T
t key. |
static int |
KEY_TAB
tab key. |
static int |
KEY_U
u key. |
static int |
KEY_UNDERLINE
_ key (NEC PC98). |
static int |
KEY_UNLABELED
(J3100). |
static int |
KEY_UP
up arrow key. |
static int |
KEY_V
v key. |
static int |
KEY_W
w key. |
static int |
KEY_X
x key. |
static int |
KEY_Y
y key. |
static int |
KEY_YEN
yen key (Japanese). |
static int |
KEY_Z
z key. |
protected java.util.List<KeyInputListener> |
listeners
list of event listeners. |
Constructor Summary | |
---|---|
KeyInput()
|
Method Summary | |
---|---|
void |
addListener(KeyInputListener listener)
Subscribe a listener to receive mouse events. |
abstract void |
clear()
|
abstract void |
clearKey(int keycode)
|
boolean |
containsListener(KeyInputListener listener)
Check if a listener is already added to this KeyInput |
protected abstract void |
destroy()
destroy frees the keyboard for use by other applications. |
static void |
destroyIfInitalized()
Destroy the input if it was initialized. |
static KeyInput |
get()
|
abstract int |
getKeyIndex(java.lang.String name)
The reverse of getKeyName, returns the value of the key given the name |
abstract java.lang.String |
getKeyName(int key)
getKeyName returns the string prepresentation of a
key code. |
java.util.List<KeyInputListener> |
getListeners()
Get all added key listeners |
static java.lang.Class<?> |
getProvider()
Query current provider for input. |
boolean |
isControlDown()
|
static boolean |
isInited()
isInited returns true if the key class is not setup
already (ie. |
abstract boolean |
isKeyDown(int key)
isKeyDown returns true if the given key is pressed. |
boolean |
isShiftDown()
|
void |
removeListener(KeyInputListener listener)
Unsubscribe a listener. |
void |
removeListeners()
Remove all listeners and disable event generation. |
static void |
setProvider(java.lang.Class value)
Change the provider used for keyboard input. |
static void |
setProvider(java.lang.String value)
Change the provider used for keyboard input. |
abstract void |
update()
Updates the current state of the keyboard, holding information about what keys are pressed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int KEY_ESCAPE
public static final int KEY_1
public static final int KEY_2
public static final int KEY_3
public static final int KEY_4
public static final int KEY_5
public static final int KEY_6
public static final int KEY_7
public static final int KEY_8
public static final int KEY_9
public static final int KEY_0
public static final int KEY_MINUS
public static final int KEY_EQUALS
public static final int KEY_BACK
public static final int KEY_TAB
public static final int KEY_Q
public static final int KEY_W
public static final int KEY_E
public static final int KEY_R
public static final int KEY_T
public static final int KEY_Y
public static final int KEY_U
public static final int KEY_I
public static final int KEY_O
public static final int KEY_P
public static final int KEY_LBRACKET
public static final int KEY_RBRACKET
public static final int KEY_RETURN
public static final int KEY_LCONTROL
public static final int KEY_A
public static final int KEY_S
public static final int KEY_D
public static final int KEY_F
public static final int KEY_G
public static final int KEY_H
public static final int KEY_J
public static final int KEY_K
public static final int KEY_L
public static final int KEY_SEMICOLON
public static final int KEY_APOSTROPHE
public static final int KEY_GRAVE
public static final int KEY_LSHIFT
public static final int KEY_BACKSLASH
public static final int KEY_Z
public static final int KEY_X
public static final int KEY_C
public static final int KEY_V
public static final int KEY_B
public static final int KEY_N
public static final int KEY_M
public static final int KEY_COMMA
public static final int KEY_PERIOD
public static final int KEY_SLASH
public static final int KEY_RSHIFT
public static final int KEY_MULTIPLY
public static final int KEY_LMENU
public static final int KEY_SPACE
public static final int KEY_CAPITAL
public static final int KEY_F1
public static final int KEY_F2
public static final int KEY_F3
public static final int KEY_F4
public static final int KEY_F5
public static final int KEY_F6
public static final int KEY_F7
public static final int KEY_F8
public static final int KEY_F9
public static final int KEY_F10
public static final int KEY_NUMLOCK
public static final int KEY_SCROLL
public static final int KEY_NUMPAD7
public static final int KEY_NUMPAD8
public static final int KEY_NUMPAD9
public static final int KEY_SUBTRACT
public static final int KEY_NUMPAD4
public static final int KEY_NUMPAD5
public static final int KEY_NUMPAD6
public static final int KEY_ADD
public static final int KEY_NUMPAD1
public static final int KEY_NUMPAD2
public static final int KEY_NUMPAD3
public static final int KEY_NUMPAD0
public static final int KEY_DECIMAL
public static final int KEY_F11
public static final int KEY_F12
public static final int KEY_F13
public static final int KEY_F14
public static final int KEY_F15
public static final int KEY_KANA
public static final int KEY_CONVERT
public static final int KEY_NOCONVERT
public static final int KEY_YEN
public static final int KEY_NUMPADEQUALS
public static final int KEY_CIRCUMFLEX
public static final int KEY_AT
public static final int KEY_COLON
public static final int KEY_UNDERLINE
public static final int KEY_KANJI
public static final int KEY_STOP
public static final int KEY_AX
public static final int KEY_UNLABELED
public static final int KEY_NUMPADENTER
public static final int KEY_RCONTROL
public static final int KEY_NUMPADCOMMA
public static final int KEY_DIVIDE
public static final int KEY_SYSRQ
public static final int KEY_RMENU
public static final int KEY_PAUSE
public static final int KEY_HOME
public static final int KEY_UP
public static final int KEY_PRIOR
public static final int KEY_PGUP
public static final int KEY_LEFT
public static final int KEY_RIGHT
public static final int KEY_END
public static final int KEY_DOWN
public static final int KEY_NEXT
public static final int KEY_PGDN
public static final int KEY_INSERT
public static final int KEY_DELETE
public static final int KEY_LMETA
public static final int KEY_LWIN
public static final int KEY_RMETA
public static final int KEY_RWIN
public static final int KEY_APPS
public static final int KEY_POWER
public static final int KEY_SLEEP
protected java.util.List<KeyInputListener> listeners
public static final java.lang.String INPUT_LWJGL
public static final java.lang.String INPUT_AWT
Constructor Detail |
---|
public KeyInput()
Method Detail |
---|
public static KeyInput get()
getProvider()
public static java.lang.Class<?> getProvider()
public static void setProvider(java.lang.String value)
INPUT_LWJGL
.
value
- new provider class name
java.lang.IllegalStateException
- if called after first call of get()
. Note that get is called when
creating the DisplaySystem.
java.lang.IllegalArgumentException
- if the specified class cannot be found using Class.forName(String)
public static void setProvider(java.lang.Class value)
InputSystem.INPUT_SYSTEM_LWJGL
.
value
- new provider
java.lang.IllegalStateException
- if called after first call of get()
. Note that get is called when
creating the DisplaySystem.public abstract boolean isKeyDown(int key)
isKeyDown
returns true if the given key is pressed. False
otherwise.
key
- the keycode to check for.
public static boolean isInited()
isInited
returns true if the key class is not setup
already (ie. .get() was not yet called).
public abstract java.lang.String getKeyName(int key)
getKeyName
returns the string prepresentation of a
key code.
key
- the key code to check.
public abstract int getKeyIndex(java.lang.String name)
name
-
public abstract void update()
update
in class Input
protected abstract void destroy()
destroy
frees the keyboard for use by other applications.
Destroy is protected now - please is destroyIfInitalized()
.
public void addListener(KeyInputListener listener)
listener
- to be subscribedpublic void removeListener(KeyInputListener listener)
listener
- to be unsubcribedaddListener(KeyInputListener)
public void removeListeners()
public boolean containsListener(KeyInputListener listener)
listener
- listener to check for
public java.util.List<KeyInputListener> getListeners()
public static void destroyIfInitalized()
public boolean isShiftDown()
public boolean isControlDown()
public abstract void clear()
public abstract void clearKey(int keycode)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |