I know I can detect a single backspace keypress like this:
$("#myelement").bind ("keyup", function(event) {
if (event.keyCode==8) {
alert ("Backspaced!!!");
}
});
How would I detect double backspace that happens say within 1 second, just like double click?
On jQuery.com itself, within their custom.js file, is a bit of code that might be helpful for you. It listens for the “konami” code in the users keystrokes. If it detects a certain sequence of keys, shown below in the variable
konami, it responds.What this code doesn’t do is track the time between the last keypress, and our current keypress. But note, with a few slight modifications, we can mimic their code and produce the desired output that you want as well.