// Use only onkeydown which return event with lots of data
function sKey(e)
{
// console.log(e);
// try: console.log(e.key,e.code,e.keyCode,e.shiftKey,e.ctrlKey,e.altKey);
switch (e.key) {
case "Shift" :
if(e.code == 'ShiftLeft') {
alert("Shift Left");
return false;
} else {
alert("Shift Right");
return false;
}
break;
case "Control" :
alert("Control");
return false;
break;
case "f" : // check for a key
if (e.ctrlKey) {
alert("Find");
return false;
} else
return true;
break;
case "s" : // check for a key
if (e.ctrlKey) {
alert("Save");
return false;
} else
return true;
break;
case "Tab" : // check for a key
alert("TAB");
return false;
break;
case "Escape" :
alert("ESC");
return false;
break;
default :
return true;
}
}
</script>
<body>
textarea cols="56" spellcheck="true" rows="12"
onkeydown="return sKey(event);"></textarea>
</body>