# Checking the state of pressed down keys

**URL:** <https://discourse.glfw.org/t/checking-the-state-of-pressed-down-keys/1462>\
**Category:** dev\
**Created:** [December 21, 2019, 7:51pm UTC](https://discourse.glfw.org/t/checking-the-state-of-pressed-down-keys/1462 "2019-12-21T19:51:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackywhite](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/jackywhite/32/567_2.png) [@jackywhite](https://discourse.glfw.org/u/jackywhite)\
**Post date:** [December 21, 2019, 7:51pm UTC](https://discourse.glfw.org/t/checking-the-state-of-pressed-down-keys/1462/1 "2019-12-21T19:51:53Z")

</div>

Have you thought about using `XQueryKeymap()` to check the state of currently pressed down keys in X11, instead of doing this manually through KeyPress and KeyRelease events?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [December 22, 2019, 11:30am UTC](https://discourse.glfw.org/t/checking-the-state-of-pressed-down-keys/1462/2 "2019-12-22T11:30:18Z")

</div>

GLFW handles input via both input callbacks and queries such as `glfwGetKey()`. The callbacks need event processing, and GLFW then stores the key state in a platform agnostic structure so that the [code for glfwGetKey is multi-platform](https://github.com/glfw/glfw/blob/master/src/input.c#L629-L650).

So using `XQueryKeymap()` isn’t required, and adding it would add to the volume of code needed to be maintained. Since we already have the data in GLFW, the current approach is also likely somewhat faster.
