phoenix::Keyboard

Provides asynchronous access to the keyboard.

struct Keyboard {
  static bool pressed(Keyboard::Scancode scancode);
  static bool released(Keyboard::Scancode scancode);
  static array<bool> state();
};

static bool Keyboard::pressed(Keyboard::Scancode scancode);

Returns true if the given scancode is currently being pressed.

static bool Keyboard::released(Keyboard::Scancode scancode);

Returns true if the given scancode is not currently being pressed.

static array<bool> Keyboard::state();

Returns the state of all keyboard scancodes, true if they are currently being pressed. array::size() == Keyboard::Scancode::Limit.

Use this function if you wish to read many key states in a row. Keyboard::pressed() has to reach out to the operating system for each call, whereas this function on some platforms will only have to do so once to get the entire keyboard state.

Example:

auto state = Keyboard::state();
if(state[(unsigned)Keyboard::Scancode::A]) a_is_being_pressed();