jQuery: How to execute a code after pressing 2 or more keys? -
remember how execute cheat on gta? want execute code in jquery when pressed combination of keys. possible in jquery? example, want display alert when press ctrl + h + e + l + l + o
. can teach me how it?
tested , working:
var combo = 'hello'; var keys = []; function onkeyup(evt) { if (!evt.ctrlkey) return; keys.push(string.fromcharcode(evt.keycode).tolowercase()); if (keys.length > combo.length) keys.shift(); if (keys.join('') == combo) //you have match }
Comments
Post a Comment