155
rated 0 times
[
162]
[
7]
/ answers: 1 / hits: 21649
/ 14 Years ago, sat, june 26, 2010, 12:00:00
<html>
<head>
<title>Test</title>
<script type=text/javascript>
function showChar(e) {
if (e.keyCode != 16) {
alert(
keyCode: + e.keyCode + n
+ SHIFT key pressed: + e.shiftKey + n
);
}
}
</script>
</head>
<body onkeydown=showChar(event);>
<p>Press any character key, with or without holding down
the SHIFT key.<br /></p>
</body>
</html>
How can I differentiate capital A from lowercase a in onkeydown event handler method? Above algorithm fires the same keyCode value. I need to detect the capital letters when they are pressed in onkeydown.
Note: The code contains an exception for SHIFT key. Otherwise it does not allow to type capital letters. BTW, I need to use onkeydown for my trial.
More From » onkeydown