mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-15 19:50:28 +03:00
Add hotkey ctrl+k for search
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
413188c995
commit
fbeecc0479
5 changed files with 52 additions and 32 deletions
24
src/client/event/hotkeys.js
Normal file
24
src/client/event/hotkeys.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { openSearch } from '../action/navigation';
|
||||
import navigation from '../state/navigation';
|
||||
|
||||
function listenKeyboard(event) {
|
||||
// Ctrl +
|
||||
if (event.ctrlKey) {
|
||||
// k - for search Modal
|
||||
if (event.keyCode === 75) {
|
||||
if (navigation.isRawModalVisible) return;
|
||||
event.preventDefault();
|
||||
openSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initHotkeys() {
|
||||
document.body.addEventListener('keydown', listenKeyboard);
|
||||
}
|
||||
|
||||
function removeHotkeys() {
|
||||
document.body.removeEventListener('keydown', listenKeyboard);
|
||||
}
|
||||
|
||||
export { initHotkeys, removeHotkeys };
|
||||
Loading…
Add table
Add a link
Reference in a new issue