@
zou8944 我加断点和调试代码试了下
self.keydownListener = async function (event) {
console.log(event); // 我添加的调试代码
// Ctrl+Shift+F 或 Command+Shift+F 呼出搜索框
if (event.ctrlKey || event.metaKey) {
if (event.shiftKey && event.key === 'f') {
按 Ctrl + Shift + F 会出来 3 条 log:
KeyboardEvent {isTrusted: true, key: 'Control', code: 'ControlLeft', location: 1, ctrlKey: true, …}
KeyboardEvent {isTrusted: true, key: 'Shift', code: 'ShiftLeft', location: 1, ctrlKey: true, …}
KeyboardEvent {isTrusted: true, key: 'F', code: 'KeyF', location: 0, ctrlKey: true, …}
这么看应该是 'f' 大小写的问题, event.key === 'f' 换成 event.keyCode = 70 就好了
另外,单独按 F 键时, event.key 是 'f', 变成大写应该和按了 Shift 有关系