Timothy Jaeryang Baek 3 ay önce
ebeveyn
işleme
d5fe0f6067
2 değiştirilmiş dosya ile 13 ekleme ve 15 silme
  1. 10 10
      src/lib/shortcuts.ts
  2. 3 5
      src/routes/(app)/+layout.svelte

+ 10 - 10
src/lib/shortcuts.ts

@@ -45,12 +45,12 @@ export const shortcuts: ShortcutRegistry = {
 	//Chat
 	//Chat
 	[Shortcut.NEW_CHAT]: {
 	[Shortcut.NEW_CHAT]: {
 		name: 'New Chat',
 		name: 'New Chat',
-		keys: ['mod', 'shift', 'KeyO'],
+		keys: ['mod', 'shift', 'O'],
 		category: 'Chat'
 		category: 'Chat'
 	},
 	},
 	[Shortcut.NEW_TEMPORARY_CHAT]: {
 	[Shortcut.NEW_TEMPORARY_CHAT]: {
 		name: 'New Temporary Chat',
 		name: 'New Temporary Chat',
-		keys: ['mod', 'shift', 'Quote'],
+		keys: ['mod', 'shift', `'`],
 		category: 'Chat'
 		category: 'Chat'
 	},
 	},
 	[Shortcut.DELETE_CHAT]: {
 	[Shortcut.DELETE_CHAT]: {
@@ -62,22 +62,22 @@ export const shortcuts: ShortcutRegistry = {
 	//Global
 	//Global
 	[Shortcut.SEARCH]: {
 	[Shortcut.SEARCH]: {
 		name: 'Search',
 		name: 'Search',
-		keys: ['mod', 'KeyK'],
+		keys: ['mod', 'K'],
 		category: 'Global'
 		category: 'Global'
 	},
 	},
 	[Shortcut.OPEN_SETTINGS]: {
 	[Shortcut.OPEN_SETTINGS]: {
 		name: 'Open Settings',
 		name: 'Open Settings',
-		keys: ['mod', 'Period'],
+		keys: ['mod', '.'],
 		category: 'Global'
 		category: 'Global'
 	},
 	},
 	[Shortcut.SHOW_SHORTCUTS]: {
 	[Shortcut.SHOW_SHORTCUTS]: {
 		name: 'Show Shortcuts',
 		name: 'Show Shortcuts',
-		keys: ['mod', 'Slash'],
+		keys: ['mod', '/'],
 		category: 'Global'
 		category: 'Global'
 	},
 	},
 	[Shortcut.TOGGLE_SIDEBAR]: {
 	[Shortcut.TOGGLE_SIDEBAR]: {
 		name: 'Toggle Sidebar',
 		name: 'Toggle Sidebar',
-		keys: ['mod', 'shift', 'KeyS'],
+		keys: ['mod', 'shift', 'S'],
 		category: 'Global'
 		category: 'Global'
 	},
 	},
 	[Shortcut.CLOSE_MODAL]: {
 	[Shortcut.CLOSE_MODAL]: {
@@ -99,7 +99,7 @@ export const shortcuts: ShortcutRegistry = {
 	},
 	},
 	[Shortcut.PREVENT_FILE_CREATION]: {
 	[Shortcut.PREVENT_FILE_CREATION]: {
 		name: 'Prevent File Creation',
 		name: 'Prevent File Creation',
-		keys: ['mod', 'shift', 'KeyV'],
+		keys: ['mod', 'shift', 'V'],
 		category: 'Input',
 		category: 'Input',
 		tooltip: 'Only active when "Paste Large Text as File" setting is toggled on.'
 		tooltip: 'Only active when "Paste Large Text as File" setting is toggled on.'
 	},
 	},
@@ -128,7 +128,7 @@ export const shortcuts: ShortcutRegistry = {
 	},
 	},
 	[Shortcut.REGENERATE_RESPONSE]: {
 	[Shortcut.REGENERATE_RESPONSE]: {
 		name: 'Regenerate Response',
 		name: 'Regenerate Response',
-		keys: ['mod', 'KeyR'],
+		keys: ['mod', 'R'],
 		category: 'Message'
 		category: 'Message'
 	},
 	},
 	[Shortcut.STOP_GENERATING]: {
 	[Shortcut.STOP_GENERATING]: {
@@ -145,12 +145,12 @@ export const shortcuts: ShortcutRegistry = {
 	},
 	},
 	[Shortcut.COPY_LAST_RESPONSE]: {
 	[Shortcut.COPY_LAST_RESPONSE]: {
 		name: 'Copy Last Response',
 		name: 'Copy Last Response',
-		keys: ['mod', 'shift', 'KeyC'],
+		keys: ['mod', 'shift', 'C'],
 		category: 'Message'
 		category: 'Message'
 	},
 	},
 	[Shortcut.COPY_LAST_CODE_BLOCK]: {
 	[Shortcut.COPY_LAST_CODE_BLOCK]: {
 		name: 'Copy Last Code Block',
 		name: 'Copy Last Code Block',
-		keys: ['mod', 'shift', 'Semicolon'],
+		keys: ['mod', 'shift', ';'],
 		category: 'Message'
 		category: 'Message'
 	}
 	}
 };
 };

+ 3 - 5
src/routes/(app)/+layout.svelte

@@ -168,17 +168,15 @@
 		const isShortcutMatch = (event: KeyboardEvent, shortcut): boolean => {
 		const isShortcutMatch = (event: KeyboardEvent, shortcut): boolean => {
 			const keys = shortcut?.keys || [];
 			const keys = shortcut?.keys || [];
 
 
-			const mainKeys = keys.filter(
-				(k) => !['ctrl', 'Ctrl', 'shift', 'Shift', 'alt', 'Alt', 'mod', 'Mod'].includes(k)
-			);
-
 			const normalized = keys.map((k) => k.toLowerCase());
 			const normalized = keys.map((k) => k.toLowerCase());
 			const needCtrl = normalized.includes('ctrl') || normalized.includes('mod');
 			const needCtrl = normalized.includes('ctrl') || normalized.includes('mod');
 			const needShift = normalized.includes('shift');
 			const needShift = normalized.includes('shift');
 			const needAlt = normalized.includes('alt');
 			const needAlt = normalized.includes('alt');
 
 
+			const mainKeys = normalized.filter((k) => !['ctrl', 'shift', 'alt', 'mod'].includes(k));
+
 			// Get the main key pressed
 			// Get the main key pressed
-			const keyPressed = event.code;
+			const keyPressed = event.key.toLowerCase();
 
 
 			// Check modifiers
 			// Check modifiers
 			if (needShift && !event.shiftKey) return false;
 			if (needShift && !event.shiftKey) return false;