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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -