I want to alert the key that the user is pressed, so I used this jQuery keyup event handler:
$(document).ready(function(e) {
$(".moveup").keyup(function() {
alert(e.keyCode)
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input class="moveup" type="text" placeholder="Press key for Up move" id="textset" name="upmove" />
All keys that I press I get "undefined". I am using chrome browser. what can be the problem?
e.keycode is undefined add the e to your keyup function
$(document).ready(function(){
$( ".moveup" ).keyup(function(e) {
alert(e.keyCode)
});
});