It must be called event in an inline event. event is not a keyword and is not a reserved word in JavaScript; it is merely the variable name the early Netscape engineers decided upon.
The inline text supplied for the event is effectively wrapped 1 as:
function (event) {
// the inline code
}
IE uses the window.event property to pass event information, but the names coincide so using event will fallback through the normal JavaScript variable resolution as appropriate.
Of course, if attaching a function object directly then the event variable, because it's just the first parameter, can be named whatever is desired. Unfortunately IE's window.event approach must be dealt with as well, and calling the argument event doesn't address it.
elm.onclick = function (my_event_name) {
my_event_name ||= window.event // for IE
...
}
(I would recommend avoiding inline events as much as possible and using a library that unifies/simplifies events.)
Happy coding!
1 This behavior is covered in detail in HTML 5: Event Handlers, Event handler content attributes:
[inline event, e.g onclick, text] must contain valid JavaScript code which, when parsed, would match [a function] production ..
Using the script execution environment created above, create a function object .. Let the function have a single argument called event.
eventis a keyword in this case and it won't work with anything else. Now in your function, you can name the parameter anything you want. DEMO