Skip to content
Advertisement

Tag: key

KeyboardEvent.keyCode deprecated. What does this mean in practice?

According to MDN, we should most definitely not be using the .keyCode property. It is deprecated: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode On W3 school, this fact is played down and there is only a side note saying that .keyCode is provided for compatibility only and that the latest version of the DOM Events Specification recommend using the .key property instead. The problem is that

Javascript why onClick getting called by enter-key

I’ve got a button with the onClick-event and a textfield with onKeyDown-event. Somehow the button is getting called if I press the enter-key and I don’t know why. Answer When you press Enter in a text field, you trigger a form submission and browsers simulate clicking on the first submit button of the form. You can avoid this by preventing

How to iterate array keys in Javascript?

I have an array created with this code: I want to get each of the values 46, 66, 90 in a loop. I tried for (var key in widthRange) but this gives me a whole bunch of extra properties (I assume they are functions on the object). I can’t use a regular for loop since the values are not sequential.

Advertisement