Skip to content

Commit 6793b9a

Browse files
committed
fix: use event.code for cross-platform keyboard shortcut compatibility
- Replace event.key checks with event.code === "Period" for both shortcuts - Fixes keyboard layout compatibility issue where Shift+Period produces different characters on non-US layouts - Consolidates both shortcuts into a single conditional block for better maintainability - Addresses feedback from @daniel-lxs in PR #5695
1 parent f76a359 commit 6793b9a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,15 +1567,18 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
15671567
// Add keyboard event handler
15681568
const handleKeyDown = useCallback(
15691569
(event: KeyboardEvent) => {
1570-
// Check for Command + . (period) for next mode
1571-
if ((event.metaKey || event.ctrlKey) && !event.shiftKey && event.key === ".") {
1570+
// Check for Command/Ctrl + Period (with or without Shift)
1571+
// Using event.code for better cross-platform compatibility
1572+
if ((event.metaKey || event.ctrlKey) && event.code === "Period") {
15721573
event.preventDefault() // Prevent default browser behavior
1573-
switchToNextMode()
1574-
}
1575-
// Check for Command + Shift + . (period) for previous mode
1576-
else if ((event.metaKey || event.ctrlKey) && event.shiftKey && event.key === ">") {
1577-
event.preventDefault() // Prevent default browser behavior
1578-
switchToPreviousMode()
1574+
1575+
if (event.shiftKey) {
1576+
// Shift + Period = Previous mode
1577+
switchToPreviousMode()
1578+
} else {
1579+
// Just Period = Next mode
1580+
switchToNextMode()
1581+
}
15791582
}
15801583
},
15811584
[switchToNextMode, switchToPreviousMode],

0 commit comments

Comments
 (0)