Code for recording keypress