|
61 | 61 | 9: "tab", |
62 | 62 | 10: "return", |
63 | 63 | 13: "return", |
64 | | - // 16: null, 17: null, 18: null, // ignore shift, ctrl, alt |
| 64 | + // 16: null, 17: null, 18: null, // ignore shift, ctrl, alt |
65 | 65 | 19: "pause", |
66 | 66 | 20: "capslock", |
67 | 67 | 27: "esc", |
|
78 | 78 | 46: "del", |
79 | 79 | 59: ";", |
80 | 80 | 61: "=", |
| 81 | + // 91: null, 93: null, // ignore left and right meta |
81 | 82 | 96: "0", |
82 | 83 | 97: "1", |
83 | 84 | 98: "2", |
|
120 | 121 | 221: "]", |
121 | 122 | 222: "'", |
122 | 123 | }, |
| 124 | + MODIFIERS = { |
| 125 | + 16: "shift", |
| 126 | + 17: "ctrl", |
| 127 | + 18: "alt", |
| 128 | + 91: "meta", |
| 129 | + 93: "meta", |
| 130 | + }, |
123 | 131 | MOUSE_BUTTONS = { 0: "", 1: "left", 2: "middle", 3: "right" }, |
124 | 132 | // Boolean attributes that can be set with equivalent class names in the LI tags |
125 | 133 | // Note: v2.23: checkbox and hideCheckbox are *not* in this list |
|
3805 | 3813 | ctx.targetType === "title" && |
3806 | 3814 | ctx.options.clickFolderMode === 4 |
3807 | 3815 | ) { |
3808 | | - // this.nodeSetFocus(ctx); |
3809 | | - // this._callHook("nodeSetActive", ctx, true); |
| 3816 | + // this.nodeSetFocus(ctx); |
| 3817 | + // this._callHook("nodeSetActive", ctx, true); |
3810 | 3818 | this._callHook("nodeToggleExpanded", ctx); |
3811 | 3819 | } |
3812 | 3820 | // TODO: prevent text selection on dblclicks |
|
3830 | 3838 | tree = ctx.tree, |
3831 | 3839 | opts = ctx.options, |
3832 | 3840 | which = event.which, |
3833 | | - whichChar = String.fromCharCode(which), |
3834 | | - clean = !( |
3835 | | - event.altKey || |
3836 | | - event.ctrlKey || |
3837 | | - event.metaKey || |
3838 | | - event.shiftKey |
3839 | | - ), |
| 3841 | + // #909: Use event.key, to get unicode characters. |
| 3842 | + // We can't use `/\w/.test(key)`, because that would |
| 3843 | + // only detect plain ascii alpha-numerics. But we still need |
| 3844 | + // to ignore modifier-only, whitespace, cursor-keys, etc. |
| 3845 | + key = event.key || String.fromCharCode(which), |
| 3846 | + isAlnum = !MODIFIERS[which] && !SPECIAL_KEYCODES[which], |
3840 | 3847 | $target = $(event.target), |
3841 | 3848 | handled = true, |
3842 | 3849 | activate = !(event.ctrlKey || !opts.autoActivate); |
3843 | 3850 |
|
3844 | 3851 | // (node || FT).debug("ftnode.nodeKeydown(" + event.type + "): ftnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which); |
3845 | | - // FT.debug("eventToString", which, '"' + String.fromCharCode(which) + '"', '"' + FT.eventToString(event) + '"'); |
| 3852 | + // FT.debug( "eventToString(): " + FT.eventToString(event) + ", key='" + key + "', isAlnum: " + isAlnum ); |
3846 | 3853 |
|
3847 | 3854 | // Set focus to active (or first node) if no other node has the focus yet |
3848 | 3855 | if (!node) { |
|
3856 | 3863 |
|
3857 | 3864 | if ( |
3858 | 3865 | opts.quicksearch && |
3859 | | - clean && |
3860 | | - /\w/.test(whichChar) && |
3861 | | - !SPECIAL_KEYCODES[which] && // #659 |
| 3866 | + isAlnum && |
3862 | 3867 | !$target.is(":input:enabled") |
3863 | 3868 | ) { |
3864 | 3869 | // Allow to search for longer streaks if typed in quickly |
|
3867 | 3872 | tree.lastQuicksearchTerm = ""; |
3868 | 3873 | } |
3869 | 3874 | tree.lastQuicksearchTime = stamp; |
3870 | | - tree.lastQuicksearchTerm += whichChar; |
| 3875 | + tree.lastQuicksearchTerm += key; |
3871 | 3876 | // tree.debug("quicksearch find", tree.lastQuicksearchTerm); |
3872 | 3877 | matchNode = tree.findNextNode( |
3873 | 3878 | tree.lastQuicksearchTerm, |
|
0 commit comments