refactored keypress handling
Merge pull request #16 from ondras/master

refactored keypress handling