orion-engine
Version:
A simple and lightweight web based game development library
159 lines (158 loc) • 4.88 kB
TypeScript
import { InputManagerInterface, KeyCode, MouseButton } from './types';
export declare class InputManager implements InputManagerInterface {
private _keys_down;
private _mouse_position;
private _mouse_buttons_down;
get keys_down(): {
CapsLock: boolean;
NumLock: boolean;
Backquote: boolean;
Digit1: boolean;
Digit2: boolean;
Digit3: boolean;
Digit4: boolean;
Digit5: boolean;
Digit6: boolean;
Digit7: boolean;
Digit8: boolean;
Digit9: boolean;
Digit0: boolean;
Minus: boolean;
Equal: boolean;
Backspace: boolean;
Tab: boolean;
KeyQ: boolean;
KeyW: boolean;
KeyE: boolean;
KeyR: boolean;
KeyT: boolean;
KeyY: boolean;
KeyU: boolean;
KeyI: boolean;
KeyO: boolean;
KeyP: boolean;
BracketLeft: boolean;
BracketRight: boolean;
Backslash: boolean;
KeyA: boolean;
KeyS: boolean;
KeyD: boolean;
KeyF: boolean;
KeyG: boolean;
KeyH: boolean;
KeyJ: boolean;
KeyK: boolean;
KeyL: boolean;
Semicolon: boolean;
Quote: boolean;
Enter: boolean;
ShiftLeft: boolean;
KeyZ: boolean;
KeyX: boolean;
KeyC: boolean;
KeyV: boolean;
KeyB: boolean;
KeyN: boolean;
KeyM: boolean;
Comma: boolean;
Period: boolean;
Slash: boolean;
ShiftRight: boolean;
ControlLeft: boolean;
MetaLeft: boolean;
AltLeft: boolean;
Space: boolean;
AltRight: boolean;
MetaRight: boolean;
ContextMenu: boolean;
ControlRight: boolean;
Insert: boolean;
Home: boolean;
PageUp: boolean;
Delete: boolean;
End: boolean;
PageDown: boolean;
ArrowUp: boolean;
ArrowLeft: boolean;
ArrowDown: boolean;
ArrowRight: boolean;
NumpadDivide: boolean;
NumpadMultiply: boolean;
NumpadSubtract: boolean;
Numpad7: boolean;
Numpad8: boolean;
Numpad9: boolean;
NumpadAdd: boolean;
Numpad4: boolean;
Numpad5: boolean;
Numpad6: boolean;
Numpad1: boolean;
Numpad2: boolean;
Numpad3: boolean;
Numpad0: boolean;
NumpadDecimal: boolean;
IntlBackslash: boolean;
F1: boolean;
F2: boolean;
F3: boolean;
F4: boolean;
F5: boolean;
F6: boolean;
F7: boolean;
F8: boolean;
F9: boolean;
F10: boolean;
F11: boolean;
F12: boolean;
AudioVolumeMute: boolean;
AudioVolumeDown: boolean;
AudioVolumeUp: boolean;
MediaTrackPrevious: boolean;
MediaTrackNext: boolean;
MediaStop: boolean;
MediaPlayPause: boolean;
NumpadEqual: boolean;
IntlYen: boolean;
};
get mouse_position(): {
x: number;
y: number;
};
get mouse_buttons_down(): {
Left: boolean;
Middle: boolean;
Right: boolean;
};
constructor();
/**
* Checks if a specific key is currently held down.
* @param key_code The key code to check.
* @returns A boolean representing whether the key is currently held down.
*/
is_key_down(key_code: KeyCode): boolean;
/**
* Checks if a specific mouse button is currently held down.
* @param button The mouse button to check.
* @returns A boolean representing whether the mouse button is currently held down.
*/
is_mouse_button_down(button: MouseButton): boolean;
/**
* Converts a string key code to a KeyCode value.
* @param key The key code as a string.
* @returns The KeyCode value, or null if the key code is not recognized.
*/
get_key_code_from_string(key: string): KeyCode | null;
/**
* Converts a numeric mouse button code to a MouseButton value.
* @param button The mouse button code as a number.
* @returns The MouseButton value, or null if the mouse button is not recognized.
*/
get_mouse_button_from_number(button: number): MouseButton | null;
/**
* Listens for a key up event on a specific key code and executes a callback function when the event is triggered.
* @param key The key code to listen for.
* @param callback The function to execute when the key up event is triggered.
* The function receives the key code as a parameter.
*/
listen_key_up(key: KeyCode, callback: (key_code: KeyCode) => void): void;
}