diff --git a/src/App.tsx b/src/App.tsx index 285c46f..caef3e1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,12 +1,14 @@ -import React from 'react' +import { useEffect } from 'react' // import 'rsuite/dist/styles/rsuite-dark.css' import './App.css' import { HTML5Backend } from 'react-dnd-html5-backend' import { DndProvider } from 'react-dnd' import { Header, Content, Footer, Generate, FlowGenerate } from './components' -import { HashRouter as Router, Route, Routes } from 'react-router-dom' +import { Route, Routes, useNavigate } from 'react-router-dom' import { ErrorBoundary } from './ErrorBoundary' import { FLAGS } from 'flags' +import { useDispatch } from 'react-redux' +import { toggleBuilderAction } from 'redux/actions' console.log( `%c @@ -29,46 +31,55 @@ console.log( ) function App() { + const dispatch = useDispatch() + const navigate = useNavigate() + useEffect(() => { + const handleKeydown = ({ key }: KeyboardEvent) => { + if (key === 'b' || key === 'B') { + dispatch(toggleBuilderAction()) + } else if (key === 'g' || key === 'G') { + navigate('/generate') + } + } + document.addEventListener('keydown', handleKeydown) + return () => document.removeEventListener('keydown', handleKeydown) + }) + return ( - - -
- - - -