Tag Archives: esc

How to Detect an ESC key press using jQuery? CodeUnit 07 AUG 2012

As per usual, the always brilliant jQuery javascript library makes it particularly easy to detect and act on a keyboard button press action. For this particular snippet we are interesting in binding our function to the user hitting the Escape (ESC) on their keyboard.

To achieve this, we make use of jQuery’s keyup listener method and bind it to the document itself. Then making use of the useful keyCode parameter passed in by the browser, we simply check for the code associated with the ESC key and act.

In practice:

$(document).keyup(function(e) {
if (e.keyCode == 27) { 
   alert('Esc key pressed!');

Simple and effective.

Windows Keyboard Shortcut: Quick, Launch the Task Manager! CodeUnit 11 JUL 2011

Here’s a nifty Windows keyboard shortcut which I was not aware of until recently. My version of Vista tends to freeze a lot, meaning a lot of sluggish trips through to the Open Task Manager button on the Control+Alt+Delete screen. However, with this particular keyboard shortcut, you can launch Task Manager directly, which is pretty awesome if your machine is about to keel over and you don’t want the poor thing struggling to draw new and unnecessary windows!

To launch, simply press Control+Shift+Escape, which will quick launch task manager in the blink of an eye.