(evt)
| 2673 | editorInfo.ace_isWordChar = isWordChar; |
| 2674 | |
| 2675 | const handleKeyEvent = (evt) => { |
| 2676 | if (!isEditable) return; |
| 2677 | const {type, charCode, keyCode, which, shiftKey} = evt; |
| 2678 | |
| 2679 | // If DOM3 support exists, ensure that the left ALT key was pressed. This |
| 2680 | // allows keyboard layouts with special meaning for right-alt-char to |
| 2681 | // continue working on Firefox / macOS. |
| 2682 | let altKey = evt.altKey; |
| 2683 | if (evt.originalEvent.location !== undefined) { |
| 2684 | altKey = altKey && evt.originalEvent.location === evt.originalEvent.DOM_KEY_LOCATION_LEFT; |
| 2685 | } |
| 2686 | |
| 2687 | // Don't take action based on modifier keys going up and down. |
| 2688 | // Modifier keys do not generate "keypress" events. |
| 2689 | // 224 is the command-key under Mac Firefox. |
| 2690 | // 91 is the Windows key in IE; it is ASCII for open-bracket but isn't the keycode for that key |
| 2691 | // 20 is capslock in IE. |
| 2692 | const isModKey = !charCode && (type === 'keyup' || type === 'keydown') && |
| 2693 | (keyCode === 16 || keyCode === 17 || keyCode === 18 || |
| 2694 | keyCode === 20 || keyCode === 224 || keyCode === 91); |
| 2695 | if (isModKey) return; |
| 2696 | |
| 2697 | // If the key is a keypress and the browser is opera and the key is enter, |
| 2698 | // do nothign at all as this fires twice. |
| 2699 | if (keyCode === 13 && browser.opera && type === 'keypress') { |
| 2700 | // This stops double enters in Opera but double Tabs still show on single |
| 2701 | // tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice |
| 2702 | return; |
| 2703 | } |
| 2704 | |
| 2705 | const isTypeForSpecialKey = browser.safari || browser.chrome || browser.firefox |
| 2706 | ? type === 'keydown' : type === 'keypress'; |
| 2707 | const isTypeForCmdKey = browser.safari || browser.chrome || browser.firefox |
| 2708 | ? type === 'keydown' : type === 'keypress'; |
| 2709 | |
| 2710 | let stopped = false; |
| 2711 | |
| 2712 | inCallStackIfNecessary('handleKeyEvent', function () { |
| 2713 | if (type === 'keypress' || (isTypeForSpecialKey && keyCode === 13 /* return*/)) { |
| 2714 | // in IE, special keys don't send keypress, the keydown does the action |
| 2715 | if (!outsideKeyPress(evt)) { |
| 2716 | evt.preventDefault(); |
| 2717 | stopped = true; |
| 2718 | } |
| 2719 | } else if (evt.key === 'Dead') { |
| 2720 | // If it's a dead key we don't want to do any Etherpad behavior. |
| 2721 | stopped = true; |
| 2722 | return true; |
| 2723 | } else if (type === 'keydown') { |
| 2724 | outsideKeyDown(evt); |
| 2725 | } |
| 2726 | let specialHandled = false; |
| 2727 | if (!stopped) { |
| 2728 | const specialHandledInHook = hooks.callAll('aceKeyEvent', { |
| 2729 | callstack: currentCallStack, |
| 2730 | editorInfo, |
| 2731 | rep, |
| 2732 | documentAttributeManager, |
nothing calls this directly
no test coverage detected