I'm using some jQuery to link the Enter key to an HTML button using the following code:
$("#console").keyup(function(event){
if(event.keyCode == 13) {
$("#submit").click();
}
});
HTML:
<input autocomplete="off" type="text" id="console" placeholder="/help, /attack, /heal, /flee" autofocus></input>
<input type="submit" onclick="play()" id="submit" value="Enter"></input>
For some reason, it's not working for me right now. There's no error message, it seems like the jQuery doesn't even run.
What am I doing wrong? Do I have to replace event
with something?
Err... a beginner's mistake...
I forgot to use:
$(document).ready(function() {
});
Nothing provoked the code to run in the first place so it never worked. Noticed it in Teemu's fiddle.