Hi i know this is probably a silly question but i only started to learn javascript today but i was wondering if someone could help me or point me in the right direction i'm wondering how can i stop a function from running that fires on keydown when a user is typing in the input
javascript
window.addEventListener("onkeydown", keyDown, true);
window.addEventListener("keydown", keyDown);
function keyDown(e) {
switch (e.keyCode) {
case 86: // Key V = myFunction
myFunction();
break;
}
}
function myFunction() {
// do something
console.log("oh no the function fired why typing in the input!")
}
input
<input type="text" name="message" class="chat-input" placeholder="Enter your chat message..." maxlength="140">