within an event handler, check if a specified key was pressed.