mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 06:06:41 +01:00
Add keyboard shortcut to toggle cloak mode
This commit is contained in:
parent
5cb0621f34
commit
f5808b6f3b
2 changed files with 19 additions and 0 deletions
|
@ -1,7 +1,9 @@
|
|||
import { memo } from 'preact/compat';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
import showToast from '../utils/show-toast';
|
||||
import states, { saveStatus } from '../utils/states';
|
||||
import useInterval from '../utils/useInterval';
|
||||
import usePageVisibility from '../utils/usePageVisibility';
|
||||
|
@ -92,5 +94,14 @@ export default memo(function BackgroundService({ isLoggedIn }) {
|
|||
}
|
||||
});
|
||||
|
||||
// Global keyboard shortcuts "service"
|
||||
useHotkeys('shift+alt+k', () => {
|
||||
const currentCloakMode = states.settings.cloakMode;
|
||||
states.settings.cloakMode = !currentCloakMode;
|
||||
showToast({
|
||||
text: `Cloak mode ${currentCloakMode ? 'disabled' : 'enabled'}`,
|
||||
});
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -154,6 +154,14 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
action: 'Bookmark',
|
||||
keys: <kbd>d</kbd>,
|
||||
},
|
||||
{
|
||||
action: 'Toggle Cloak mode',
|
||||
keys: (
|
||||
<>
|
||||
<kbd>Shift</kbd> + <kbd>Alt</kbd> + <kbd>k</kbd>
|
||||
</>
|
||||
),
|
||||
},
|
||||
].map(({ action, keys }) => (
|
||||
<tr key={action}>
|
||||
<th>{action}</th>
|
||||
|
|
Loading…
Reference in a new issue