Skip to content

Commit

Permalink
fix: keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
invm authored and Michael Ionov committed Jan 18, 2024
1 parent 51ee5c3 commit 80b7b7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/UI/Keymaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { For } from 'solid-js';
const keymaps = [
{ action: 'Help', keys: ['F1'] },
{ action: 'Execute query', keys: ['Ctrl', 'E/Enter'] },
{ action: 'Select tab', keys: ['Ctrl/Cmd', 'number'] },
{ action: 'Select connection tab', keys: ['Ctrl/Cmd', 'Shift', 'number'] },
{ action: 'Select tab', keys: ['Alt/Cmd', 'number'] },
{ action: 'Select connection tab', keys: ['Ctrl/Cmd', 'number'] },
{ action: 'New tab', keys: ['Ctrl/Cmd', 'T'] },
{ action: 'Close current tab', keys: ['Ctrl/Cmd', 'W'] },
{ action: 'Focus on editor', keys: ['Ctrl', 'L'] },
Expand Down
24 changes: 17 additions & 7 deletions src/services/RegisterKeymaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ export const RegisterKeymaps = (props: { children: JSXElement; osType: OsType })
const CmdOrCtrl = isMac ? 'Meta' : 'Control';
setAppStore({ osType: props.osType });

if (isMac) {
for (let i = 1; i <= 9; i++) {
createShortcut(['Meta', String(i)], () => {
setContentIdx(i - 1);
});
}
} else {
for (let i = 1; i <= 9; i++) {
createShortcut(['Alt', String(i)], () => {
setContentIdx(i - 1);
});
}
}


createShortcut(['F1'], () => {
setComponent((s) => (s === 1 ? 0 : 1));
});
Expand All @@ -41,15 +56,10 @@ export const RegisterKeymaps = (props: { children: JSXElement; osType: OsType })
});

for (let i = 1; i <= 9; i++) {
createShortcut([CmdOrCtrl, String(i)], () => {
setContentIdx(i - 1);
});
}

for (let i = 1; i <= 9; i++) {
createShortcut([CmdOrCtrl, 'Shift', String(i)], () => {
createShortcut(['Control', String(i)], () => {
setConnectionIdx(i - 1);
});
}

return props.children;
};

0 comments on commit 80b7b7a

Please sign in to comment.