UNPKG

shimi

Version:

A JS framework for building complex MIDI applications

360 lines (359 loc) 12.4 kB
import ButtonInput from './ButtonInput'; import { ClockChildFinishedEvent, IClockChild } from './Clock'; import { IEventSubscriber } from './EventSubscriber'; /** * The Keyboard class models a computer keyboard, providing ButtonInput properties for all of the keys found on most standard English computer keyboards (coverage of other language keyboards is currently unconfirmed). * * @category User Inputs */ export default class Keyboard implements IClockChild { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** The collection of all ButtonInputs that the Keyboard holds. */ get buttons(): ButtonInput[]; private _buttons; /** Provides a way of identifying keyboards so they can be easily retrieved later. */ get ref(): string; set ref(value: string); private _ref; /** If true, then the keyboard has been deactivated and marked for disposal. */ get isFinished(): boolean; private _isFinished; /** This event fires when the keyboard has been deactivated and marked for disposal. */ get finished(): ClockChildFinishedEvent; private _finished; /** ButtonInput for the Escape key. */ get escape(): ButtonInput; private _escape; /** ButtonInput for the F1 key. */ get f1(): ButtonInput; private _f1; /** ButtonInput for the F2 key. */ get f2(): ButtonInput; private _f2; /** ButtonInput for the F3 key. */ get f3(): ButtonInput; private _f3; /** ButtonInput for the F4 key. */ get f4(): ButtonInput; private _f4; /** ButtonInput for the F5 key. */ get f5(): ButtonInput; private _f5; /** ButtonInput for the F6 key. */ get f6(): ButtonInput; private _f6; /** ButtonInput for the F7 key. */ get f7(): ButtonInput; private _f7; /** ButtonInput for the F8 key. */ get f8(): ButtonInput; private _f8; /** ButtonInput for the F9 key. */ get f9(): ButtonInput; private _f9; /** ButtonInput for the F10 key. */ get f10(): ButtonInput; private _f10; /** ButtonInput for the F11 key. */ get f11(): ButtonInput; private _f11; /** ButtonInput for the F12 key. */ get f12(): ButtonInput; private _f12; /** ButtonInput for the Backquote `` ` `` key. */ get backquote(): ButtonInput; private _backquote; /** ButtonInput for the 1 key in the numbers row. */ get numrow1(): ButtonInput; private _numrow1; /** ButtonInput for the 2 key in the numbers row. */ get numrow2(): ButtonInput; private _numrow2; /** ButtonInput for the 3 key in the numbers row. */ get numrow3(): ButtonInput; private _numrow3; /** ButtonInput for the 4 key in the numbers row. */ get numrow4(): ButtonInput; private _numrow4; /** ButtonInput for the 5 key in the numbers row. */ get numrow5(): ButtonInput; private _numrow5; /** ButtonInput for the 6 key in the numbers row. */ get numrow6(): ButtonInput; private _numrow6; /** ButtonInput for the 7 key in the numbers row. */ get numrow7(): ButtonInput; private _numrow7; /** ButtonInput for the 8 key in the numbers row. */ get numrow8(): ButtonInput; private _numrow8; /** ButtonInput for the 9 key in the numbers row. */ get numrow9(): ButtonInput; private _numrow9; /** ButtonInput for the 0 key in the numbers row. */ get numrow0(): ButtonInput; private _numrow0; /** ButtonInput for the Minus key in the numbers row. */ get minus(): ButtonInput; private _minus; /** ButtonInput for the Equal key in the numbers row. */ get equal(): ButtonInput; private _equal; /** ButtonInput for the Backspace key in the numbers row. */ get backspace(): ButtonInput; private _backspace; /** ButtonInput for the Tab key. */ get tab(): ButtonInput; private _tab; /** ButtonInput for the Q key. */ get q(): ButtonInput; private _q; /** ButtonInput for the W key. */ get w(): ButtonInput; private _w; /** ButtonInput for the E key. */ get e(): ButtonInput; private _e; /** ButtonInput for the R key. */ get r(): ButtonInput; private _r; /** ButtonInput for the T key. */ get t(): ButtonInput; private _t; /** ButtonInput for the Y key. */ get y(): ButtonInput; private _y; /** ButtonInput for the U key. */ get u(): ButtonInput; private _u; /** ButtonInput for the I key. */ get i(): ButtonInput; private _i; /** ButtonInput for the O key. */ get o(): ButtonInput; private _o; /** ButtonInput for the P key. */ get p(): ButtonInput; private _p; /** ButtonInput for the Left Bracket `[` key. */ get leftBracket(): ButtonInput; private _leftBracket; /** ButtonInput for the Right Bracket `]` key. */ get rightBracket(): ButtonInput; private _rightBracket; /** ButtonInput for the Enter key. */ get enter(): ButtonInput; private _enter; /** ButtonInput for the Caps Lock key. */ get capslock(): ButtonInput; private _capslock; /** ButtonInput for the A key. */ get a(): ButtonInput; private _a; /** ButtonInput for the S key. */ get s(): ButtonInput; private _s; /** ButtonInput for the D key. */ get d(): ButtonInput; private _d; /** ButtonInput for the F key. */ get f(): ButtonInput; private _f; /** ButtonInput for the G key. */ get g(): ButtonInput; private _g; /** ButtonInput for the H key. */ get h(): ButtonInput; private _h; /** ButtonInput for the J key. */ get j(): ButtonInput; private _j; /** ButtonInput for the K key. */ get k(): ButtonInput; private _k; /** ButtonInput for the L key. */ get l(): ButtonInput; private _l; /** ButtonInput for the Semicolon `;` key. */ get semicolon(): ButtonInput; private _semicolon; /** ButtonInput for the Quote `'` key. */ get quote(): ButtonInput; private _quote; /** ButtonInput for the Backslash `\` key. */ get backslash(): ButtonInput; private _backslash; /** ButtonInput for the Left Shift key. */ get leftShift(): ButtonInput; private _leftShift; /** ButtonInput for the Backslash `\` key on non-American keyboards (typically located next to the left shift key). */ get intlBackslash(): ButtonInput; private _intlBackslash; /** ButtonInput for the Z key. */ get z(): ButtonInput; private _z; /** ButtonInput for the X key. */ get x(): ButtonInput; private _x; /** ButtonInput for the C key. */ get c(): ButtonInput; private _c; /** ButtonInput for the V key. */ get v(): ButtonInput; private _v; /** ButtonInput for the B key. */ get b(): ButtonInput; private _b; /** ButtonInput for the N key. */ get n(): ButtonInput; private _n; /** ButtonInput for the M key. */ get m(): ButtonInput; private _m; /** ButtonInput for the Comma `,` key. */ get comma(): ButtonInput; private _comma; /** ButtonInput for the Period `.` key. */ get period(): ButtonInput; private _period; /** ButtonInput for the Slash `/` key. */ get slash(): ButtonInput; private _slash; /** ButtonInput for the Right Shift key. */ get rightShift(): ButtonInput; private _rightShift; /** ButtonInput for the Left Control key. */ get leftCtrl(): ButtonInput; private _leftCtrl; /** ButtonInput for the Left Alt key. */ get leftAlt(): ButtonInput; private _leftAlt; /** ButtonInput for the Spacebar. */ get space(): ButtonInput; private _space; /** ButtonInput for the Right Alt key. */ get rightAlt(): ButtonInput; private _rightAlt; /** ButtonInput for the Right Control key. */ get rightCtrl(): ButtonInput; private _rightCtrl; /** ButtonInput for the Insert key. */ get insert(): ButtonInput; private _insert; /** ButtonInput for the Home key. */ get home(): ButtonInput; private _home; /** ButtonInput for the Page Up key. */ get pageUp(): ButtonInput; private _pageUp; /** ButtonInput for the Delete key. */ get delete(): ButtonInput; private _delete; /** ButtonInput for the End key. */ get end(): ButtonInput; private _end; /** ButtonInput for the Page Down key. */ get pageDown(): ButtonInput; private _pageDown; /** ButtonInput for the Up arrow key. */ get up(): ButtonInput; private _up; /** ButtonInput for the Left arrow key. */ get left(): ButtonInput; private _left; /** ButtonInput for the Down arrow key. */ get down(): ButtonInput; private _down; /** ButtonInput for the Right arrow key. */ get right(): ButtonInput; private _right; /** ButtonInput for the Num Lock key. */ get numlock(): ButtonInput; private _numlock; /** ButtonInput for the Divide `/` key in the numpad. */ get numpadDivide(): ButtonInput; private _numpadDivide; /** ButtonInput for the Multiply `*` key in the numpad. */ get numpadMultiply(): ButtonInput; private _numpadMultiply; /** ButtonInput for the Subtract `-` key in the numpad. */ get numpadSubtract(): ButtonInput; private _numpadSubtract; /** ButtonInput for the 7 key in the numpad. */ get numpad7(): ButtonInput; private _numpad7; /** ButtonInput for the 8 key in the numpad. */ get numpad8(): ButtonInput; private _numpad8; /** ButtonInput for the 9 key in the numpad. */ get numpad9(): ButtonInput; private _numpad9; /** ButtonInput for the Add `+` key in the numpad. */ get numpadAdd(): ButtonInput; private _numpadAdd; /** ButtonInput for the 4 key in the numpad. */ get numpad4(): ButtonInput; private _numpad4; /** ButtonInput for the 5 key in the numpad. */ get numpad5(): ButtonInput; private _numpad5; /** ButtonInput for the 6 key in the numpad. */ get numpad6(): ButtonInput; private _numpad6; /** ButtonInput for the 1 key in the numpad. */ get numpad1(): ButtonInput; private _numpad1; /** ButtonInput for the 2 key in the numpad. */ get numpad2(): ButtonInput; private _numpad2; /** ButtonInput for the 3 key in the numpad. */ get numpad3(): ButtonInput; private _numpad3; /** ButtonInput for the Enter key in the numpad. */ get numpadEnter(): ButtonInput; private _numpadEnter; /** ButtonInput for the 0 key in the numpad. */ get numpad0(): ButtonInput; private _numpad0; /** ButtonInput for the Decimal `.` key in the numpad. */ get numpadDecimal(): ButtonInput; private _numpadDecimal; private _eventSubscriber; /** * @param eventSubscriber The passed in event subscriber should wrap around the document object, allowing the keyboard to subscribe to keyup & keydown events when the `activate()` method is called. */ constructor(eventSubscriber: IEventSubscriber); private _activated; /** * Start listening to keyboard events. * @returns Returns false if the keyboard was already activated and nothing needed to be done. Otherwise returns true. */ activate(): boolean; /** * Stop listening to keyboard events. * @returns Returns false if the keyboard wasn't already activated and nothing needed to be done. Otherwise returns true. */ deactivate(): boolean; /** Calling this tells the Keyboard to deactivate itself and that it will no longer be used. */ finish(): void; /** * Provides a way for setting the ref through a chained function call. For example: * * ``` * clock.addChild(new Keyboard(new EventSubscriber(document)).withRef('keyboard')); * ``` * * @param ref The ref to set on the object. * @returns The calling object. */ withRef(ref: string): IClockChild; private _onKeyDown; private _onKeyUp; private _getButtonByEventCode; /** * This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library. * @param deltaMs How many milliseconds have passed since the last update cycle. */ update(deltaMs: number): void; }