Fix error if weird key is pressed

Closes #542