JAVASCRIPT display pressing key left, right, down, up on keyboard javascript - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

how to display the pressing key left, right, down, up on the keyboard in javascript ?


 69

JAVASCRIPT


0


<!DOCTYPE html>
<html>
<head>
</head>
<body>

<script type="text/javascript">

window.addEventListener("keydown", uniCharCode, false);

function uniCharCode(event) {

var keyCode = event.which || event.keyCode;
var elem = document.getElementById("cube");

if (keyCode == 37) {

alert("left"); //left arrow key


}

if (keyCode == 38) {

alert("up"); //up arrow key


}

if (keyCode == 39) {

alert("right") //right arrow key


}

if (keyCode == 40) {

alert("down"); //down arrow key



}

}

</script>

</body>
</html> 


By     Created   
The power of the user (%)
65%



The most helpful JAVASCRIPT solutions

How to get client machine name or computer name with javascript ?How to get client machine name or computer name with javascript ?JAVASCRIPT

Click to see more ...

  3.9K     367

get client hostname javascriptget client hostname javascriptJAVASCRIPT

Click to see more ...

  2.1K     249

detect ie javascriptdetect ie javascriptJAVASCRIPT

Click to see more ...

  1.3K     152

get ip address javascriptget ip address javascriptJAVASCRIPT

Click to see more ...

  690     74

how to create foreach class using javascript ?how to create foreach class using javascript ?JAVASCRIPT

Click to see more ...

  520     69

create qr code javascriptcreate qr code javascriptJAVASCRIPT

Click to see more ...

  469     67

How replace reverse solidus using javascript ?How replace reverse solidus using javascript ?JAVASCRIPT

Click to see more ...

  327     54

get current url using javascriptget current url using javascriptJAVASCRIPT

Click to see more ...

  305     52

get filename using javascript get filename using javascript JAVASCRIPT

Click to see more ...

  295     45

how to create the connect to a database with ADODB using javascript ?how to create the connect to a database with ADODB using javascript ?JAVASCRIPT

Click to see more ...

  277     43