simplify keypress check with key object