本文整理匯總了TypeScript中@angular/platform-browser/src/dom/events/key_events.KeyEventsPlugin類的典型用法代碼示例。如果您正苦於以下問題:TypeScript KeyEventsPlugin類的具體用法?TypeScript KeyEventsPlugin怎麽用?TypeScript KeyEventsPlugin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了KeyEventsPlugin類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should correctly parse event names', () => {
// key with no modifier
expect(KeyEventsPlugin.parseEventName('keydown.enter'))
.toEqual({'domEventName': 'keydown', 'fullKey': 'enter'});
expect(KeyEventsPlugin.parseEventName('keyup.enter'))
.toEqual({'domEventName': 'keyup', 'fullKey': 'enter'});
// key with modifiers:
expect(KeyEventsPlugin.parseEventName('keydown.control.shift.enter'))
.toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift.enter'});
expect(KeyEventsPlugin.parseEventName('keyup.control.shift.enter'))
.toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift.enter'});
// key with modifiers in a different order:
expect(KeyEventsPlugin.parseEventName('keydown.shift.control.enter'))
.toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift.enter'});
expect(KeyEventsPlugin.parseEventName('keyup.shift.control.enter'))
.toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift.enter'});
// key that is also a modifier:
expect(KeyEventsPlugin.parseEventName('keydown.shift.control'))
.toEqual({'domEventName': 'keydown', 'fullKey': 'shift.control'});
expect(KeyEventsPlugin.parseEventName('keyup.shift.control'))
.toEqual({'domEventName': 'keyup', 'fullKey': 'shift.control'});
expect(KeyEventsPlugin.parseEventName('keydown.control.shift'))
.toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift'});
expect(KeyEventsPlugin.parseEventName('keyup.control.shift'))
.toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift'});
});
示例2: it
it('should implement addGlobalEventListener', () => {
const plugin = new KeyEventsPlugin(document);
spyOn(plugin, 'addEventListener').and.callFake(() => {});
expect(() => plugin.addGlobalEventListener('window', 'keyup.control.esc', () => {}))
.not.toThrowError();
});
示例3: expect
expect(() => plugin.addGlobalEventListener('window', 'keyup.control.esc', () => {}))