export class KeyboardManager { private pressingKeys : { [ key ] : boolean ; } = { } ; private lastPressing : string | null = null ; public onKeyDown ( event ) { this . pressingKeys [ event . code ] = true ; this . lastPressing = event . code ; } public onKeyUp ( event ) { this . pressingKeys [ event . code ] = false ; if ( this . lastPressing === event . code ) this . lastPressing = null ; } public clear ( ) { Object . keys ( this . pressingKeys ) . forEach ( key => ( this . pressingKeys [ key ] = false ) ) ; } public getKeyPressing ( key ) { return this . pressingKeys [ key ] === true ; } public getLastPressing ( ) { return this . lastPressing ; } }