refactor isKeyPressed function - so that is works with key codes too