|
|
@ -577,6 +577,30 @@ describe('\n Hotkeys.js Test Case222.\n', () => {
|
|
|
|
hotkeys.unbind('⌃+a');
|
|
|
|
hotkeys.unbind('⌃+a');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('HotKeys Key single callback Test Case', async () => {
|
|
|
|
|
|
|
|
hotkeys('ctrl+s', () => {
|
|
|
|
|
|
|
|
expect(false).toBeTruthy();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
hotkeys('ctrl+s', { single: true }, (e) => {
|
|
|
|
|
|
|
|
expect(e.keyCode).toBe(83);
|
|
|
|
|
|
|
|
expect(e.ctrlKey).toBeTruthy();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
hotkeys('ctrl+shift+s', { single: true }, (e) => {
|
|
|
|
|
|
|
|
expect(e.shiftKey).toBeTruthy();
|
|
|
|
|
|
|
|
expect(e.keyCode).toBe(83);
|
|
|
|
|
|
|
|
expect(e.ctrlKey).toBeTruthy();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
__triggerKeyboardEvent(document.body, 83, {
|
|
|
|
|
|
|
|
ctrlKey: true,
|
|
|
|
|
|
|
|
shiftKey: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
__triggerKeyboardEvent(document.body, 83, {
|
|
|
|
|
|
|
|
ctrlKey: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect.assertions(5);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// const _modifier = { //修饰键
|
|
|
|
// const _modifier = { //修饰键
|
|
|
|
// '⇧': 16, shift: 16,
|
|
|
|
// '⇧': 16, shift: 16,
|
|
|
|
// '⌥': 18, alt: 18, option: 18,
|
|
|
|
// '⌥': 18, alt: 18, option: 18,
|
|
|
|