diff --git a/docs/shortcuts.md b/docs/shortcuts.md index f28de7e..363dfdb 100644 --- a/docs/shortcuts.md +++ b/docs/shortcuts.md @@ -1,11 +1,11 @@ ## Available Shortcuts -| Key | Description | -| ------------------------------- | ---------------------------- | -| shift + s | Open Settings Modal | -| R or r | Refresh data | -| shift + l | Switch display to line chart | -| shift + b | Switch display to bar chart | -| shift + t | Switch display to table | -| | Switch stats to previous | -| | Switch stats to next | +| Key | Description | +| ------------------------------ | ---------------------------- | +| ctrl + s | Open Settings Modal | +| ctrl + r | Refresh data | +| ctrl + l | Switch display to line chart | +| ctrl + b | Switch display to bar chart | +| ctrl + t | Switch display to table | +| | Switch stats to previous | +| | Switch stats to next | diff --git a/renderer/components/DataDisplay/index.js b/renderer/components/DataDisplay/index.js index 0644a52..447546d 100644 --- a/renderer/components/DataDisplay/index.js +++ b/renderer/components/DataDisplay/index.js @@ -44,9 +44,9 @@ const Chart = ({ }; // Shortcuts - useHotkeys("shift+b", () => setStyle("bar chart")); - useHotkeys("shift+l", () => setStyle("line chart")); - useHotkeys("shift+t", () => setStyle("table")); + useHotkeys("ctrl+b", () => setStyle("bar chart")); + useHotkeys("ctrl+l", () => setStyle("line chart")); + useHotkeys("ctrl+t", () => setStyle("table")); return ( <> diff --git a/renderer/components/NavigationBar/index.js b/renderer/components/NavigationBar/index.js index 999862d..4269d72 100644 --- a/renderer/components/NavigationBar/index.js +++ b/renderer/components/NavigationBar/index.js @@ -19,6 +19,7 @@ import Settings from "../Settings"; import CustomIntervalModal from "./CustomIntervalModal"; +import { useHotkeys } from "react-hotkeys-hook"; import { useVnStat } from "@Context/vnStat"; import { useConfig } from "@Context/configration"; @@ -62,21 +63,13 @@ export default function NavigationBar() { }); }, []); - function PressKeyHandler(e) { - if (e.key === "R" || e.key === "r") { - reloadConfigs(); - reloadingTrafficData(); - router.replace(router.asPath); - } - } - - useEffect(() => { - window.addEventListener("keydown", PressKeyHandler); - - return () => window.removeEventListener("keydown", PressKeyHandler); // Cleanup - }, [PressKeyHandler]); + useHotkeys("ctrl+r", () => { + reloadConfigs(); + reloadingTrafficData(); + router.replace(router.asPath); + }); - // For debugging + // ! For debugging // useEffect(() => { // console.log(Page); // console.log(router.pathname, router.asPath); diff --git a/renderer/components/Settings/index.js b/renderer/components/Settings/index.js index e29ce16..7f470d6 100644 --- a/renderer/components/Settings/index.js +++ b/renderer/components/Settings/index.js @@ -64,7 +64,7 @@ export default function Settings({ children }) { } = useVnStat(); const { config } = useConfig(); - useHotkeys("shift+s", onOpen); + useHotkeys("ctrl+s", onOpen); return ( <>