-
-
Notifications
You must be signed in to change notification settings - Fork 308
Keyboard Input design
AZhan edited this page Apr 23, 2022
·
4 revisions
When implementing the input system, we made compatibility for all inputs, this keyboard event can be implemented very simply. Input system design
/**
* Input Manager.
*/
export class InputManager {
/**
* Whether the key is being held down, if there is no parameter, return whether any key is being held down.
* @param key - The keys of the keyboard
* @returns Whether the key is being held down.
*/
isKeyHeldDown(key?: Keys): boolean {}
/**
* Whether the key starts to be pressed down during the current frame, if there is no parameter, return whether any key starts to be pressed down during the current frame.
* @param key - The keys of the keyboard
* @returns Whether the key starts to be pressed down during the current frame.
*/
isKeyDown(key?: Keys): boolean {}
/**
* Whether the key is released during the current frame, if there is no parameter, return whether any key released during the current frame.
* @param key - The keys of the keyboard
* @returns Whether the key is released during the current frame.
*/
isKeyUp(key?: Keys): boolean {}
}
/**
* The keys of the keyboard.
* Keep up with W3C standards.(https://www.w3.org/TR/2017/CR-uievents-code-20170601/)
*/
export enum Keys {
//...
}