class method Input.observe
Input.observe(eventName, handler) → Input
-
eventName
(String
) – The name of the input event to observe. See below. -
handler
(Function
) – The function to execute wheneventName
occurs.
Sets the engine to call Function handler
when input event eventName
occurs from the user. Allowed eventName
values are:
keydown
: Called when a key is pressed down. The term "key" is meantto be used loosley, as in, a game client that contains a keyboard should call this for each key pressed. If the client contains is a portable gaming device, this should be called for each button pressed on the controller. The `Input.KEY_*` values should be used as the "basic" keyCode values. Optionally, the `keyCode` property in the argument object can be used to determine more precisely which key was pressed.
keyup
: Called when a key is released. Seekeydown
above for moredetails.
mousemove
: Called continually as the mouse moves across the game screen.The `x` and `y` properties in the argument object can be used to determine the mouse position.
mousedown
: Called when any of the mouse keys are pressed down. The`button` value in the argument object can be used to determine which mouse button was pressed, along with `x` and `y` to determine where on the screen the button was pressed down.
mouseup
: Called when any of the mouse keys are released. The`button` value in the argument object can be used to determine which mouse button was pressed, along with `x` and `y` to determine where on the screen the button was pressed released.