Package io.github.espressoengine.input
Class KeyHandler
java.lang.Object
io.github.espressoengine.input.KeyHandler
Class to handle input from keyboards.
- Version:
- $Id: $Id
- Author:
- pastthepixels
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
getAxis
(int negativeKeyCode, int positiveKeyCode) Similar to Godot's getAxis.Gets a list of all keys currently being pressed down.boolean
isKeyPressed
(int keyCode) Returns true if a keycode is in the list of pressed keys.void
Is called whenever a key is pressed, and is designed to be overridden on class instances as an event.void
Is called whenever a key is released, and is designed to be overridden on class instances as an event.
-
Field Details
-
dbg
public boolean dbg -
pressedKeys
-
-
Constructor Details
-
KeyHandler
Constructor for KeyHandler.
- Parameters:
window
- aWindow
object
-
-
Method Details
-
getPressedKeys
Gets a list of all keys currently being pressed down.- Returns:
- a
ArrayList
object
-
isKeyPressed
public boolean isKeyPressed(int keyCode) Returns true if a keycode is in the list of pressed keys.
- Parameters:
keyCode
- a int- Returns:
- a boolean
-
getAxis
public double getAxis(int negativeKeyCode, int positiveKeyCode) Similar to Godot's getAxis. Returns -1 if the key under
negativeKeyCode
is pressed, 1 if the key underpositiveKeyCode
is pressed, and 0 if none or both of them are pressed.- Parameters:
negativeKeyCode
- a intpositiveKeyCode
- a int- Returns:
- a double
-
onKeyPressed
Is called whenever a key is pressed, and is designed to be overridden on class instances as an event.- Parameters:
e
- aKeyEvent
object
-
onKeyReleased
Is called whenever a key is released, and is designed to be overridden on class instances as an event.- Parameters:
e
- aKeyEvent
object
-