Skip to content

Commit

Permalink
runfix: use keyboardjs library for config toolbar keyboard shortcut (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Gira authored Sep 13, 2024
1 parent 4697848 commit 11c3d2b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/script/components/ConfigToolbar/ConfigToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

import {useState, useEffect, useRef} from 'react';

import keyboardjs from 'keyboardjs';

import {Button, Input, Switch} from '@wireapp/react-ui-kit';

import {Config, Configuration} from 'src/script/Config';
import {useClickOutside} from 'src/script/hooks/useClickOutside';
import {isMetaKey} from 'Util/KeyboardUtil';

import {wrapperStyles} from './ConfigToolbar.styles';

Expand All @@ -34,15 +35,14 @@ export function ConfigToolbar() {

// Toggle config tool on 'cmd/ctrl + shift + 2'
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (isMetaKey(event) && event.shiftKey && event.key === '2') {
setShowConfig(prev => !prev);
}
const handleKeyDown = () => {
setShowConfig(prev => !prev);
};

window.addEventListener('keydown', handleKeyDown);
keyboardjs.bind(['command+shift+2', 'ctrl+shift+2'], handleKeyDown);

return () => {
window.removeEventListener('keydown', handleKeyDown);
keyboardjs.unbind(['command+shift+2', 'ctrl+shift+2'], handleKeyDown);
};
}, []);

Expand Down

0 comments on commit 11c3d2b

Please sign in to comment.