event binding

document.onkeydown= keyDown; here is an assignment statement . Specifically, the meaning of this code is to bind events to keys, so a function method is bound to key events. This sentence means that the keyDown function is executed when the key is pressed . 
The latter one is not necessarily wrong, because the return value of keyDown() may be a function , that is, the method returned by keyDown() is executed when the key is pressed.
Simply put, what is required to bind an event is a reference to a function, not the result of a function call.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324550452&siteId=291194637
Recommended