Captures keyboard inputs from the user. More...
#include <Keyboard.h>
Public Member Functions | |
Keyboard () | |
Default constructor. More... | |
int | onKeyUp (Callback< Key > callback) |
Add an event listener to a key up event. More... | |
int | onKeyDown (Callback< Key > callback) |
Add an event listener to a key down event. More... | |
int | onKeyHeld (Callback< Key > callback) |
Add an event listener to a key held event. More... | |
bool | unsubscribe (KeyboardEvent event, int id) |
Remove an event listener from a key down or key up event. More... | |
void | handleEvent (Event event) |
Handle a system event. More... | |
Static Public Member Functions | |
static bool | isKeyPressed (Key key) |
Check if a key is pressed or not. More... | |
Captures keyboard inputs from the user.
You usually don't instantiate this class directly, you either use the input manager that is local to a Scene or the global input manager that from the Engine class
Definition at line 52 of file Keyboard.h.
|
strong |
keyboard key codes
Definition at line 57 of file Keyboard.h.
ime::input::Keyboard::Keyboard | ( | ) |
Default constructor.
void ime::input::Keyboard::handleEvent | ( | Event | event | ) |
Handle a system event.
event | Event to be handled |
|
static |
Check if a key is pressed or not.
key | Key to be checked |
This function checks the state of a key in real time, unlike all the other function which are event-based
Add an event listener to a key down event.
callback | Function to be executed when the key is down |
The key down event fires once when a key is depressed. If the key remains depressed a key held event fires. In other words, if you press and hold a key on the keyboard, the key down event will fire once and wil not fire again until the key is released and pressed again
Add an event listener to a key held event.
callback | Function to be executed when a key is held |
The key held event will continue to fire while a key is held down. The event always fires after a key down event. The callback is passed the key that is held down
Add an event listener to a key up event.
callback | Function to be executed when a key is released |
This event is triggered only when a depressed/held key is released. The callback is passed the key that was released
bool ime::input::Keyboard::unsubscribe | ( | KeyboardEvent | event, |
int | id | ||
) |
Remove an event listener from a key down or key up event.
event | Event to remove event listener from |
id | Identification number of the listener to be removed |