onKeyPress(key: Key | Key[], action: (key: Key)=>void): KEventController
Register an event that runs when user presses certain keys.
param
key- The key(s) to listen for.
param
action- The function to run when the event is triggered.
// .jump() once when "space" is just being pressed onKeyPress("space", () => { bean.jump(); }); onKeyPress(["up", "space"], () => { bean.jump(); });
returns
The event controller.
since
v2000.1