5. How to trap the backspace key using jQuery? I am trying to fire an Escape button press event in Angular unit tests.This does not work at all (event is never caught by listeners that do proper checking like event.which 27). What is the correct way to create such an event? jQuery. event. key jQuery. event. key. method to the jQuery event object that returns a string representation of pausebreak, caps, escape, numlock.Detect escape key press with jQuery - JSFiddle. I want to capture when the user hits Esc on a input text field on keypress, but this event key.js is certainly the simpliest shortcut key event handler ever.