# Issues with keyboard

**URL:** <https://discourse.glfw.org/t/issues-with-keyboard/43>\
**Category:** support\
**Created:** [February 23, 2014, 7:37pm UTC](https://discourse.glfw.org/t/issues-with-keyboard/43 "2014-02-23T19:37:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [February 23, 2014, 7:37pm UTC](https://discourse.glfw.org/t/issues-with-keyboard/43/1 "2014-02-23T19:37:00Z")

</div>

**[juanito88](https://sourceforge.net/u/juanito88/)** wrote on [Sunday, February 23, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/d8732c43/#dac6):

Hi all,

I wan to take inputs from the keyboard using GLFW (ver 2.7).

Keys are read as expected, except for one issue:  
Suppose I’m moving to the left (with the left key pressed). Then, if I press the up key (keeping the left key pressed), I’m able to jump, but I stopped moving to the left.  
If I release the left key and then press it back, I’m able to continue moving to the left.

How can I solve this issue?

Below there is a fragment that shows the main parts of the code:

```
:::python
# //global variable
# World world;
# 
# //callback function
# void readKey( int key, int action ) {
# world.moveGuy(key,action );
# }

# int main( int argc, char **argv ) {
# 
# //...
# glfwEnable( GLFW_KEY_REPEAT );
# glfwEnable( GLFW_STICKY_KEYS );
# 

# glfwSetKeyCallback( readKey );
# do {
# //... 
# 
# } while( !world.closeWindow);
# return error;
# }

# void World::moveGuy( int key, int action ) {
# if( action != GLFW_PRESS )
# return;
# if( key==GLFW_KEY_LEFT)
# //move left
# if( key==GLFW_KEY_RIGHT)
# //move right
# if( key==GLFW_KEY_UP)
# //jump
#}

```

Any help would be much appreciated!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [February 23, 2014, 9:02pm UTC](https://discourse.glfw.org/t/issues-with-keyboard/43/2 "2014-02-23T21:02:55Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Sunday, February 23, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/d8732c43/#d8a3):

There are two ways to do this.

The simplest is to poll glfwGetKey() for each direction key once per frame. Alternatively, you can keep track of which keys are pressed down, and then update the movement once per frame.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 1, 2014, 2:38am UTC](https://discourse.glfw.org/t/issues-with-keyboard/43/3 "2014-03-01T02:38:35Z")

</div>

**[juanito88](https://sourceforge.net/u/juanito88/)** wrote on [Saturday, March 01, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/d8732c43/#724f):

Thanks!! I tried polling, but it didn’t work.  
Using a callback function and keeping track of the stated worked@
