<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