keypress changed to keydown event to fix bug in Chrome/Safari