Skip to content

Instantly share code, notes, and snippets.

@bwsewell
Created February 8, 2013 15:22
Show Gist options
  • Save bwsewell/4739667 to your computer and use it in GitHub Desktop.
Save bwsewell/4739667 to your computer and use it in GitHub Desktop.
Capturing a double keystroke with jQuery
// Will fire an alert if user presses the "F" key twice within 300 miliseconds
var dblCtrlKey = 0;
$(document).keydown(function(e) {
if (dblCtrlKey != 0 && e.which == 70) {
alert("Ok double F");
} else {
dblCtrlKey = setTimeout('dblCtrlKey = 0;', 300);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment