adding alternate key combinations for special shift (#173)

This commit is contained in:
Hao Xiang
2025-02-22 23:00:04 +08:00
committed by GitHub
parent c6427dc724
commit a0e196a9e7
+4 -3
View File
@@ -1,8 +1,8 @@
import { type } from '@tauri-apps/plugin-os'; import { type } from '@tauri-apps/plugin-os';
import { debounce } from '@yaakapp-internal/lib';
import { useEffect, useRef } from 'react'; import { useEffect, useRef } from 'react';
import { capitalize } from '../lib/capitalize'; import { capitalize } from '../lib/capitalize';
import { useOsInfo } from './useOsInfo'; import { useOsInfo } from './useOsInfo';
import { debounce } from '@yaakapp-internal/lib';
const HOLD_KEYS = ['Shift', 'Control', 'Command', 'Alt', 'Meta']; const HOLD_KEYS = ['Shift', 'Control', 'Command', 'Alt', 'Meta'];
@@ -31,9 +31,9 @@ const hotkeys: Record<HotkeyAction, string[]> = {
'app.zoom_out': ['CmdCtrl+-'], 'app.zoom_out': ['CmdCtrl+-'],
'app.zoom_reset': ['CmdCtrl+0'], 'app.zoom_reset': ['CmdCtrl+0'],
'command_palette.toggle': ['CmdCtrl+k'], 'command_palette.toggle': ['CmdCtrl+k'],
'environmentEditor.toggle': ['CmdCtrl+Shift+e'], 'environmentEditor.toggle': ['CmdCtrl+Shift+E', 'CmdCtrl+Shift+e'],
'grpc_request.send': ['CmdCtrl+Enter', 'CmdCtrl+r'], 'grpc_request.send': ['CmdCtrl+Enter', 'CmdCtrl+r'],
'hotkeys.showHelp': ['CmdCtrl+Shift+/'], 'hotkeys.showHelp': ['CmdCtrl+Shift+/', 'CmdCtrl+Shift+?'], // when shift is pressed, it might be a question mark
'http_request.create': ['CmdCtrl+n'], 'http_request.create': ['CmdCtrl+n'],
'http_request.delete': ['Backspace'], 'http_request.delete': ['Backspace'],
'http_request.duplicate': ['CmdCtrl+d'], 'http_request.duplicate': ['CmdCtrl+d'],
@@ -115,6 +115,7 @@ export function useHotKey(
if (e.metaKey) currentKeysWithModifiers.add('Meta'); if (e.metaKey) currentKeysWithModifiers.add('Meta');
if (e.shiftKey) currentKeysWithModifiers.add('Shift'); if (e.shiftKey) currentKeysWithModifiers.add('Shift');
console.log('down', currentKeysWithModifiers);
for (const [hkAction, hkKeys] of Object.entries(hotkeys) as [HotkeyAction, string[]][]) { for (const [hkAction, hkKeys] of Object.entries(hotkeys) as [HotkeyAction, string[]][]) {
if ( if (
(e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) && (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) &&