Skip to content

Commit f92a5cb

Browse files
fix(ui): fix up hotkeys
- Add Shift+X back (this has been missing for a long time) - Add secondary toggle options hotkey
1 parent acbf10f commit f92a5cb

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,13 @@
436436
},
437437
"appHotkeys": "App Hotkeys",
438438
"cancel": {
439-
"desc": "Cancel image generation",
439+
"desc": "Cancel current queue item",
440440
"title": "Cancel"
441441
},
442+
"cancelAndClear": {
443+
"desc": "Cancel current queue item and clear all pending items",
444+
"title": "Cancel and Clear"
445+
},
442446
"changeTabs": {
443447
"desc": "Switch to another workspace",
444448
"title": "Change Tabs"

invokeai/frontend/web/src/common/hooks/useGlobalHotkeys.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { useAppDispatch } from 'app/store/storeHooks';
2+
import { useCancelCurrentQueueItem } from 'features/queue/hooks/useCancelCurrentQueueItem';
3+
import { useClearQueue } from 'features/queue/hooks/useClearQueue';
24
import { useQueueBack } from 'features/queue/hooks/useQueueBack';
35
import { useQueueFront } from 'features/queue/hooks/useQueueFront';
46
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
@@ -43,6 +45,40 @@ export const useGlobalHotkeys = () => {
4345
[queueFront, isDisabledQueueFront, isLoadingQueueFront]
4446
);
4547

48+
const {
49+
cancelQueueItem,
50+
isDisabled: isDisabledCancelQueueItem,
51+
isLoading: isLoadingCancelQueueItem,
52+
} = useCancelCurrentQueueItem();
53+
54+
useHotkeys(
55+
['shift+x', 'shift+enter'],
56+
cancelQueueItem,
57+
{
58+
enabled: () => !isDisabledCancelQueueItem && !isLoadingCancelQueueItem,
59+
preventDefault: true,
60+
enableOnFormTags: ['input', 'textarea', 'select'],
61+
},
62+
[cancelQueueItem, isDisabledCancelQueueItem, isLoadingCancelQueueItem]
63+
);
64+
65+
const {
66+
clearQueue,
67+
isDisabled: isDisabledClearQueue,
68+
isLoading: isLoadingClearQueue,
69+
} = useClearQueue();
70+
71+
useHotkeys(
72+
['ctrl+shift+x', 'meta+shift+x'],
73+
clearQueue,
74+
{
75+
enabled: () => !isDisabledClearQueue && !isLoadingClearQueue,
76+
preventDefault: true,
77+
enableOnFormTags: ['input', 'textarea', 'select'],
78+
},
79+
[clearQueue, isDisabledClearQueue, isLoadingClearQueue]
80+
);
81+
4682
useHotkeys(
4783
'1',
4884
() => {

invokeai/frontend/web/src/features/system/components/HotkeysModal/HotkeysModal.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ const HotkeysModal = ({ children }: HotkeysModalProps) => {
6868
desc: t('hotkeys.cancel.desc'),
6969
hotkey: 'Shift+X',
7070
},
71+
{
72+
title: t('hotkeys.cancelAndClear.title'),
73+
desc: t('hotkeys.cancelAndClear.desc'),
74+
hotkey: 'Shift+Ctrl+X / Shift+Cmd+X',
75+
},
7176
{
7277
title: t('hotkeys.focusPrompt.title'),
7378
desc: t('hotkeys.focusPrompt.desc'),
@@ -76,7 +81,7 @@ const HotkeysModal = ({ children }: HotkeysModalProps) => {
7681
{
7782
title: t('hotkeys.toggleOptions.title'),
7883
desc: t('hotkeys.toggleOptions.desc'),
79-
hotkey: 'O',
84+
hotkey: 'T / O',
8085
},
8186
{
8287
title: t('hotkeys.toggleGallery.title'),

invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ const InvokeTabs = () => {
207207
} = usePanel(galleryPanelUsePanelOptions);
208208

209209
useHotkeys('g', toggleGalleryPanel, []);
210-
useHotkeys('t', toggleOptionsPanel, []);
210+
useHotkeys(['t', 'o'], toggleOptionsPanel, []);
211211
useHotkeys(
212212
'f',
213213
() => {

0 commit comments

Comments
 (0)