check that keystroke is valid