You are doing it all wrong. First of all, keyboard event handlers are called with passing only one argument, not two. Therefore, your second actual argument is
undefined
. When you dereference this underfined object attempting to take
e.which
, an exception is thrown and probably not caught, and, anyway, the whole thing does not work.
Besides,
window
object does not have the property "event", with similar "results". An attempt to get
window.event
returns
underfined
, too.
You need to use a handler with only one argument, which is an event object. The actual object passed will be the
KeyboardEvent
object, which you can use to extract all the event properties you need. This is well explained here:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent[
^],
http://javascript.info/tutorial/keyboard-events[
^].
—SA