improvement!: changed I as Shortcut for Inspect

Refactored inspect element shortcut to I and implemented suggested changes
This commit is contained in:
codewithmitesh 2023-03-28 23:32:17 +05:30
parent 7413a9a13e
commit 8c307fa31d

View file

@ -13,14 +13,15 @@ import Button from '../Button';
import AddressBar from './AddressBar';
import ColorSchemeToggle from './ColorSchemeToggle';
function useKey(key, cb) {
function useKey(key: any, cb: any) {
const callbackRef = useRef(cb);
useEffect(() => {
callbackRef.current = cb;
});
useEffect(() => {
function handle(event) {
callbackRef.current = cb;
}, [cb]);
useEffect(() => {
function handle(event: { code: any }) {
if (event.code === key) {
callbackRef.current(event);
}
@ -37,7 +38,7 @@ const ToolBar = () => {
function handleInspectShortcut() {
dispatch(setIsInspecting(!isInspecting));
}
useKey('KeyS', handleInspectShortcut);
useKey('KeyI', handleInspectShortcut);
return (
<div className="flex items-center justify-between gap-2">