Skip to content Skip to sidebar Skip to footer

Object.keys(keyboardevent) Only Get One "istrusted" Key Rather Than All Keys

A function is triggered when the user is pressing a key in the input field.

functionmyFunction(event){

  console.log(Object.keys(event))
  console.log(event)
  
  for (const property in event) {
 
 if(typeof event[property] == "function"){ 
  console.log(`${property}: `+':its a  fuction');
  }else{
   console.log(`${property}: ${event[property]}`+':  its a property');
  }
}
}
<!DOCTYPE html><html><body><p>A function is triggered when the user is pressing a key in the input field.</p><inputtype="text"onkeydown="myFunction(event)"></body></html>

Post a Comment for "Object.keys(keyboardevent) Only Get One "istrusted" Key Rather Than All Keys"