Retrieve Input permanently

I want to have some kind of object with xyz coordinates that can move. Now I create a key_callback which moves the object based on the input. But when I bind the key_callback and run the program, it stops after a certain amount of time when I keep pressing a key. I think this is caused because the key_callback isnt called after a while when no event is happening. How can I bypass this to update the coordinates permanently, even if a key is held down?

Add a timer callback. Have the key callback simply keep track of whether the key is up or down, have the timer callback move the object if the key is down.