I wrote a tutorial on exactly this, let me know if any of it is confusing: Keyboard Input - Tutorials - Static Void Games