Trouvé à l'intérieurYou can respond to select events directly from each menu command by adding an event listener (also called an event handler). (See Chapter 6 for more on event listeners.) The following JavaScript example assigns the fileNew() function to ... Add event listener for loop problem in JavaScript March 06, 2018. Newsletter: The listener is programmed to react to an input or signal by calling the event's handler. event.ctrlKey: the Ctrl key; event.altKey: the Alt key; event.metaKey: the "meta" key differs based on the OS.For example, on Mac OSX it's the ⌘ Command key; event.shiftkey: the Shift key; Until recently the conventional way to listen to the keyboard was via event.keyCode instead of event.key.Many forums/blogs like StackOverflow still heavily feature keyCode however beware. Trouvé à l'intérieur – Page 69The listeners will also expose properties associated with the event. For example, if we want to add an event listener in plain JavaScript, we would add the following lines of code: