Skip to content

Commit

Permalink
feat: ctrl+space to start+stop
Browse files Browse the repository at this point in the history
  • Loading branch information
mstephen19 committed Nov 27, 2022
1 parent 50e1ed3 commit e3415ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Binary file removed build.zip
Binary file not shown.
5 changes: 5 additions & 0 deletions src/widget/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const Main = () => {
<Toaster
position="top-center"
toastOptions={{ duration: 3e3 }}
containerStyle={{
zIndex: 9e12,
pointerEvents: 'none',
userSelect: 'none',
}}
/>
<Widget />
</AutomatorProvider>
Expand Down
19 changes: 18 additions & 1 deletion src/widget/Widget.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Tabs, Tab, Button, Tag, Text, Anchor } from 'grommet';
import { lazy, useCallback } from 'react';
import { lazy, useCallback, useEffect } from 'react';
import { PlayFill, StopFill } from 'grommet-icons';
import { toast } from 'react-hot-toast';
import { useFetch, useLocalStorage } from './hooks';
Expand All @@ -14,6 +14,7 @@ import Automator, {
useAutomatorContext,
getMessages,
} from './components/Automator';

import type { LatestRelease } from '../types';

const Interests = lazy(() => import('./components/Interests'));
Expand All @@ -34,6 +35,22 @@ const Widget = () => {
setStarted((prev) => !prev);
}, [started]);

// Allow certain
useEffect(() => {
const handler = (e: KeyboardEvent) => {
switch (true) {
case e.ctrlKey && e.code === 'Space':
handleStart();
}
};

window.addEventListener('keyup', handler);

return () => {
window.removeEventListener('keyup', handler);
};
}, []);

return (
<>
<DraggableBox
Expand Down

0 comments on commit e3415ca

Please sign in to comment.