Mouse and keyboard info
Query the state of the mouse and keyboard.
Summary
Functions
Name | |
---|---|
glm::vec2 | mouse() const Returns the current mouse position. |
glm::vec2 | mouse_delta() const Returns the movement of the mouse since the last update(). |
bool | mouse_is_in_window() const Returns true iff the window is focused and the coordinates returned by mouse() correspond to a position inside the window. |
bool | mouse_button_is_pressed(Button button) constReturns true iff the given mouse button is currently pressed. |
bool | ctrl() const Returns true iff the CTRL key is pressed (or CMD on Mac) |
bool | shift() const Returns true iff the SHIFT key is pressed. |
bool | alt() const Returns true iff the ALT key is pressed. |
bool | key_is_pressed(int key) constReturns true iff the given key is currently pressed. |
Functions
mouse()
glm::vec2
mouse() const;
Returns the current mouse position.
mouse_delta()
glm::vec2
mouse_delta() const;
Returns the movement of the mouse since the last update().
mouse_is_in_window()
bool
mouse_is_in_window() const;
Returns true iff the window is focused and the coordinates returned by mouse() correspond to a position inside the window.
mouse_button_is_pressed()
bool
mouse_button_is_pressed(Button
button) const;
Returns true iff the given mouse button is currently pressed.
ctrl()
bool
ctrl() const;
Returns true iff the CTRL key is pressed (or CMD on Mac)
shift()
bool
shift() const;
Returns true iff the SHIFT key is pressed.
alt()
bool
alt() const;
Returns true iff the ALT key is pressed.
key_is_pressed()
bool
key_is_pressed(int
key) const;
Returns true iff the given key
is currently pressed.
key
should be a GLFW_KEY value. See https://www.glfw.org/docs/3.3/keys.html for the complete list. e.g. ctx.key_is_pressed(GLFW_KEY_Q)
/!\ Please note that these are physical keys that don't depend on the current layout. This means that GLFW_KEY_Q will refer to the first key on your keyboard, no matter if you are using QWERTY or AZERTY.
Updated on 2024 October 24