Fix error if weird key is pressed

Closes #542
Merge pull request #544 from almarklein/fix-weird-keys

Fix error if weird key is pressed