Key press

We can read which key is pressed by user by reading window event. We need to use onkeydown to get arrow keys status.
Press any key.

Press any key ( Demo )


Here is the sample code to read key press
<script language='JavaScript' type='text/JavaScript'>
document.onkeypress = function(key_dtl) {
 key_dtl = key_dtl || window.event; 
var uni_code = key_dtl.keyCode || key_dtl.which; 
var key_name = String.fromCharCode(uni_code); 
//alert(key_name); 
document.getElementById('my_msg').innerHTML=key_name;
}
</script>
Read how to detect arrow key press
Event Handling onMouseOver and onMouseOut

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer