|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjplay.InputBase
jplay.Keyboard
public final class Keyboard
Class responsible for handling the keys of keyboard and its behavior.
Field Summary | |
---|---|
static int |
DOWN_KEY
The direction key for under of the keyboard. |
static int |
ENTER_KEY
The enter key of the keyboard. |
static int |
ESCAPE_KEY
The ESC key of the keyboard. |
static int |
LEFT_KEY
The direction key for left of the keyboard. |
static int |
RIGHT_KEY
The direction key for right of the keyboard. |
static int |
SPACE_KEY
The space bar of the keyboard. |
static int |
UP_KEY
The direction key for above of the keyboard. |
Fields inherited from class jplay.InputBase |
---|
DETECT_EVERY_PRESS, DETECT_INITIAL_PRESS_ONLY |
Constructor Summary | |
---|---|
Keyboard()
Create instance of class Keyboard with the following keys and its behavior: UP_KEY, LEFT_KEY, RIGHT_KEY, DOWN_KEY have the behavior DETECT_EVERY_PRESS, and the keys ESCAPE_KEY, SPACE_KEY, ENTER_KEY have the behavior DETECT_INITIAL_PRESS_ONLY. |
Method Summary | |
---|---|
void |
addKey(int key)
Overloading the method void addKey(int key, int behavior), the behavior will be DETECT_INITAL_PRESS_ONLY. |
void |
addKey(int key,
int behavior)
Method used for adding a key to an instance of the keyboard and its behavior. |
boolean |
keyDown(int key)
Method used for knowing if a key is pressed. |
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
|
void |
keyTyped(java.awt.event.KeyEvent e)
|
void |
removeKey(int key)
Remove a key of the instance of the keyboard. |
void |
setBehavior(int key,
int behavior)
Set a new behavior for a key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int UP_KEY
public static final int LEFT_KEY
public static final int RIGHT_KEY
public static final int DOWN_KEY
public static final int ESCAPE_KEY
public static final int SPACE_KEY
public static final int ENTER_KEY
Constructor Detail |
---|
public Keyboard()
Method Detail |
---|
public boolean keyDown(int key)
key
- The key code presents in 'Keyboard.' or in 'KeyEvent.'
KeyEvent
,
Keyboard
public void addKey(int key)
key
- The key code. The key code can be found in 'KeyEvent.'KeyEvent
public void addKey(int key, int behavior)
key
- The key code. The key code can be found in 'KeyEvent.'.behavior
- The behavior of the key can be found in 'Keboard.' or in 'InputBase.'.KeyEvent
,
InputBase
public void removeKey(int key)
KeyEvent
,
Keyboard
public void setBehavior(int key, int behavior)
key
- The key code. It can be found in 'KeyEvent.' or in 'Keyboard.'KeyEvent
,
Keyboard
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |