Skip to content
Advertisement

Why is event.ctrlKey returning undef?

I am calling a JavaScript function when an option is selected in a select element like so:

JavaScript

The function does something like this:

JavaScript

According to the alert, e.ctrlKey is undefined – I thought this was supposed to return either true or false? What am I missing here?

Advertisement

Answer

As per the standard, the attribute ctrlKey is only available on MouseEvents (like click, mouseover, etc.) but not HTMLEvents.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement