Reputation: 65
I am trying to get the pressed key value but ... no result or it outputs "undefined". Here's the code:
<body onkeypress="checkLetter(e)" >
</body>
<script>
function checkLetter(e)
{
var mot = "aracnophobie";
var lettre = String.fromCharCode(e.keyCode);
alert(lettre);
}
</script>
Can someone help please?
Upvotes: 0
Views: 42
Reputation: 101
I'm not sure about you're trying to do, but test it with an "event" param, not "e" : onclick="checkLetter(event)"
Upvotes: 1