export class ShortcutsHelper { private shortcuts : string [ ] = [ ] ; private shortcutsVanilla : ( ( e : KeyboardEvent ) => void ) [ ] = [ ] ; private window : Window ; constructor ( window ) { this . window = window ; } public bind ( shortcut , action ) { ( < any > this . window ) . key ( shortcut , ( e ) => { action ( e ) ; } ) ; this . shortcuts . push ( shortcut ) ; } public bindVanilla ( shortcut , action ) { const listener = ( e ) => { if ( e . key . toLowerCase ( ) == shortcut ) action ( e ) ; } ; ( < any > this . window ) . addEventListener ( 'keydown' , listener ) ; this . shortcutsVanilla . push ( listener ) ; } public unBindAll ( ) { this . shortcuts . forEach ( ( shortcut ) => { this . unBind ( shortcut ) ; } ) ; this . shortcutsVanilla . forEach ( ( listener ) => { this . unBindVanilla ( listener ) ; } ) ; } public unBind ( shortcut ) { ( < any > this . window ) . key . unbind ( shortcut ) ; } public unBindVanilla ( listener ) { ( < any > this . window ) . removeEventListener ( 'keydown' , listener ) ; } }