Skip to content

Instantly share code, notes, and snippets.

@manfredovaldes
Last active August 29, 2015 13:56
Show Gist options
  • Save manfredovaldes/9310663 to your computer and use it in GitHub Desktop.
Save manfredovaldes/9310663 to your computer and use it in GitHub Desktop.
var keys = {13:'Start',16:'Select', 37: 'Left',38:'Up',39:'Right',40:'Down',65:'a',66:'b'};
var cmdCount = 0;
$(document).unbind("keydown").keydown(function(evt){
if($("#chat_text_input").is(":focus")) return;
var key = keys[evt.keyCode];
if (typeof key === 'undefined') return;
if (cmdCount % 3 === 1) key = key.toUpperCase();
else if (cmdCount % 3 === 2) key = key.toLowerCase();
cmdCount ++;
$("#chat_text_input").val(key);
$("#chat_speak").click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment