Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7fbc461
fix(devtools): support the shortcut on non-QWERTY layouts
ahmetomerv Oct 23, 2026
37f5fa9
fix(devtools): sync the shortcut with the dock state
ahmetomerv Oct 23, 2026
789a829
chore(devtools): remove redundant shortcut comment
ahmetomerv Oct 23, 2026
0929303
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 23, 2026
4437d4d
fix(devtools): hide the panel when closing from the shortcut
ahmetomerv Oct 23, 2026
f2ac809
fix(devtools): ignore stale keyboard layout results
ahmetomerv Oct 23, 2026
442ccb8
fix(devtools): open the panel when the shortcut is pressed
ahmetomerv Oct 23, 2026
58599cf
fix(devtools): drop stale shortcut codes on refresh
ahmetomerv Oct 23, 2026
498a339
fix(devtools): close the panel session when toggling
ahmetomerv Oct 23, 2026
ee20ff3
fix(devtools): keep shortcut codes empty during refresh
ahmetomerv Oct 23, 2026
0524564
Merge branch 'main' into fix/keyboard-shortcut-non-qwerty
ahmetomerv Oct 27, 2026
1a0768d
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 27, 2026
e30359a
Merge branch 'main' into fix/keyboard-shortcut-non-qwerty
ahmetomerv Oct 30, 2026
78b980e
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2026
fa8d46b
Merge branch 'main' into fix/keyboard-shortcut-non-qwerty
ahmetomerv Nov 25, 2026
6be7424
fix(devtools): slim the non-QWERTY shortcut to keyCode matching
ahmetomerv Nov 25, 2026
06b97e3
Merge branch 'main' into fix/keyboard-shortcut-non-qwerty
ahmetomerv Nov 27, 2026
5ad8768
test(devtools): drop duplicate shortcut test case
antfubot Dec 1, 2026
0aa90f9
Merge branch 'main' into fix/keyboard-shortcut-non-qwerty
antfu Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/devtools/client/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { setupFrameNav } from '~/composables/frame-nav'
import { WS_DEBOUNCE_TIME } from '~/composables/rpc'
import { registerCommands } from '~/composables/state-commands'
import { i18n } from '~/i18n'
import { isDevtoolsShortcut } from '../src/runtime/shared/shortcut'
import { wsConnectedOnce } from './composables/rpc'
import { useSchemaInput } from './composables/state-schema'
import { useDevToolsOptions } from './composables/storage-options'
Expand Down Expand Up @@ -85,7 +86,7 @@ watchEffect(() => {
})

useEventListener('keydown', (e) => {
if (e.code === 'KeyD' && e.altKey) {
if (isDevtoolsShortcut(e, false)) {
client.value?.devtools.close()
e.preventDefault()
}
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools/src/runtime/plugins/view/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { computed, effect, isRef, markRaw, nextTick, reactive, ref, shallowReact
import { useAppConfig } from '#imports'

import { initTimelineMetrics } from '../../function-metrics-helpers'
import { isDevtoolsShortcut } from '../../shared/shortcut'

// Host controls must update the visible Devframe viewer context, rather than
// Vite's separate dock-registration context. Target the shared-frame anchor
Expand Down Expand Up @@ -264,7 +265,7 @@ export async function setupDevToolsClient({

// Shortcut to toggle devtools (opens Vite DevTools panel with Nuxt DevTools entry)
window.addEventListener('keydown', (e) => {
if (e.code === 'KeyD' && e.altKey && e.shiftKey)
if (isDevtoolsShortcut(e))
client.devtools.toggle()
})
}
Expand Down
25 changes: 25 additions & 0 deletions packages/devtools/src/runtime/shared/shortcut.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// `code` is the physical QWERTY position, and on macOS Option rewrites `key`
// (`d` -> `∂` / `Î`). `keyCode` (deprecated but universally supported) follows
// the active layout and ignores modifiers.

export interface DevtoolsShortcutEvent {
altKey: boolean
shiftKey: boolean
ctrlKey?: boolean
metaKey?: boolean
key?: string
keyCode?: number
}

const D_KEY_CODE = 68

export function isDevtoolsShortcut(
event: DevtoolsShortcutEvent,
requireShift = true,
): boolean {
return event.altKey
&& (!requireShift || event.shiftKey)
&& !event.ctrlKey
&& !event.metaKey
&& (event.key?.toLowerCase() === 'd' || event.keyCode === D_KEY_CODE)
}
47 changes: 47 additions & 0 deletions packages/devtools/test/devtools-shortcut.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { describe, expect, it } from 'vitest'
import { isDevtoolsShortcut } from '../src/runtime/shared/shortcut'

function createEvent(overrides: Partial<Parameters<typeof isDevtoolsShortcut>[0]> = {}) {
return {
altKey: true,
shiftKey: true,
key: 'd',
keyCode: 68,
...overrides,
}
}

describe('isDevtoolsShortcut', () => {
it('matches Shift + Alt + D on a QWERTY layout', () => {
expect(isDevtoolsShortcut(createEvent())).toBe(true)
})

it('matches via keyCode when Option rewrites the key (macOS, Workman)', () => {
expect(isDevtoolsShortcut(createEvent({ key: 'Î' }))).toBe(true)
})

it('matches the produced key where Option does not rewrite it', () => {
expect(isDevtoolsShortcut(createEvent({ key: 'd', keyCode: 0 }))).toBe(true)
})

it('ignores keys that do not type d, like physical KeyD on Colemak', () => {
expect(isDevtoolsShortcut(createEvent({ key: 's', keyCode: 83 }))).toBe(false)
})

it('requires Alt', () => {
expect(isDevtoolsShortcut(createEvent({ altKey: false }))).toBe(false)
})

it('requires Shift when opening', () => {
expect(isDevtoolsShortcut(createEvent({ shiftKey: false }))).toBe(false)
})

it('allows Shift to be optional when closing', () => {
expect(isDevtoolsShortcut(createEvent({ shiftKey: false }), false)).toBe(true)
})

it('ignores Ctrl and Meta combinations', () => {
expect(isDevtoolsShortcut(createEvent({ ctrlKey: true }))).toBe(false)
expect(isDevtoolsShortcut(createEvent({ metaKey: true }))).toBe(false)
})
})
Loading