+ 3
onkeydown and onkeyup events not working in JavaScript... Is it just me or is it deprecated?
Im trying to use onkeyup and onkeydown events but they just won't fire. Only the keypress event works but i also want to know when the key is released. Are there any alternatives?
3 Antworten
0
<html>
<body>
<p>A function is triggered when the user is pressing a key in the input field.</p>
<input type="text" onkeydown="myFunction()">
<script>
function myFunction() {
alert("You pressed a key inside the input field");
}
</script>
</body>
</html>
0
<html>
<body>
<p>A function is triggered when the user is pressing a key in the input field.</p>
<input type="text" onkeypress="myFunction()">
<script>
function myFunction() {
alert("You pressed a key inside the input field");
}
</script>
</body>
</html>