lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
36 lines • 1.13 kB
JavaScript
import { VirtualKey } from './VirtualKey.js';
/**
* A {@link VirtualKey} which emits key presses of a given key code.
*
* @category Widget
*/
export class BasicVirtualKey extends VirtualKey {
/**
* @param text - The text to display in the virtual key.
* @param keyCode - The {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values | key code} to emit in the keyContext's callback when the virtual key is pressed
* @param keyContext - The {@link KeyContext} shared by other virtual keyboard key widgets.
*/
constructor(text, keyCode, keyContext, properties) {
super(text, () => keyContext.callback(keyCode), properties);
}
}
BasicVirtualKey.autoXML = {
name: 'basic-virtual-key',
inputConfig: [
{
mode: 'text',
name: 'text'
},
{
name: 'key-code',
mode: 'value',
validator: 'string',
},
{
name: 'key-context',
mode: 'value',
validator: 'key-context',
},
]
};
//# sourceMappingURL=BasicVirtualKey.js.map