public final class KeyboardAwt extends Object implements Keyboard, KeyListener
Constructor and Description |
---|
KeyboardAwt()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionPressed(Integer key,
EventAction action)
Add an action that will be triggered on pressed state.
|
void |
addActionReleased(Integer key,
EventAction action)
Add an action that will be triggered on released state.
|
double |
getHorizontalDirection() |
Integer |
getKeyCode()
Get the current pressed key code.
|
char |
getKeyName()
Get the current pressed key name.
|
double |
getVerticalDirection() |
boolean |
isPressed(Integer key)
Check if the key is currently pressed.
|
boolean |
isPressedOnce(Integer key)
Check if the key is currently pressed (not continuously).
|
void |
keyPressed(KeyEvent event) |
void |
keyReleased(KeyEvent event) |
void |
keyTyped(KeyEvent event) |
void |
removeActionsPressed()
Remove all pressed actions.
|
void |
removeActionsReleased()
Remove all released actions.
|
void |
setHorizontalControlNegative(Integer code) |
void |
setHorizontalControlPositive(Integer code) |
void |
setVerticalControlNegative(Integer code) |
void |
setVerticalControlPositive(Integer code) |
boolean |
used()
Check if the keyboard is currently used (at least one pressed key).
|
public void addActionPressed(Integer key, EventAction action)
Keyboard
Alternative usage with classic programming style can be achieved with Keyboard.isPressed(Integer)
or
Keyboard.isPressedOnce(Integer)
.
addActionPressed
in interface Keyboard
key
- The action key.action
- The action reference.public void addActionReleased(Integer key, EventAction action)
Keyboard
Alternative usage with classic programming style can be achieved with Keyboard.isPressed(Integer)
or
Keyboard.isPressedOnce(Integer)
.
addActionReleased
in interface Keyboard
key
- The action key.action
- The action reference.public void removeActionsPressed()
Keyboard
removeActionsPressed
in interface Keyboard
public void removeActionsReleased()
Keyboard
removeActionsReleased
in interface Keyboard
public boolean isPressed(Integer key)
Keyboard
Alternative usage with event programming style can be achieved with
Keyboard.addActionPressed(Integer, EventAction)
and Keyboard.addActionReleased(Integer, EventAction)
.
public boolean isPressedOnce(Integer key)
Keyboard
Alternative usage with event programming style can be achieved with
Keyboard.addActionPressed(Integer, EventAction)
and Keyboard.addActionReleased(Integer, EventAction)
.
isPressedOnce
in interface Keyboard
key
- The key to check.true
if pressed, false
else.public Integer getKeyCode()
Keyboard
getKeyCode
in interface Keyboard
Keyboard.NO_KEY_CODE
if key never pressed).public char getKeyName()
Keyboard
getKeyName
in interface Keyboard
public boolean used()
Keyboard
public void setHorizontalControlPositive(Integer code)
setHorizontalControlPositive
in interface InputDeviceDirectional
public void setHorizontalControlNegative(Integer code)
setHorizontalControlNegative
in interface InputDeviceDirectional
public void setVerticalControlPositive(Integer code)
setVerticalControlPositive
in interface InputDeviceDirectional
public void setVerticalControlNegative(Integer code)
setVerticalControlNegative
in interface InputDeviceDirectional
public double getHorizontalDirection()
getHorizontalDirection
in interface InputDeviceDirectional
public double getVerticalDirection()
getVerticalDirection
in interface InputDeviceDirectional
public void keyPressed(KeyEvent event)
keyPressed
in interface KeyListener
public void keyReleased(KeyEvent event)
keyReleased
in interface KeyListener
public void keyTyped(KeyEvent event)
keyTyped
in interface KeyListener
Copyright © 2017 Byron 3D Games Studio. All rights reserved.