mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-12 02:00:28 +03:00
Fix hotkeys (#1468)
* use hotkey using key instead of which (default) * remove shift from block formatting hotkeys * smartly exit formatting with backspace * set markdown to off by default * exit formatting with escape
This commit is contained in:
parent
5dc613cd79
commit
d5ff55e23e
9 changed files with 65 additions and 45 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import isHotkey from 'is-hotkey';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
import { KeyboardEventHandler } from 'react';
|
||||
|
||||
export interface KeyboardEventLike {
|
||||
|
|
@ -12,14 +12,14 @@ export interface KeyboardEventLike {
|
|||
}
|
||||
|
||||
export const onTabPress = (evt: KeyboardEventLike, callback: () => void) => {
|
||||
if (isHotkey('tab', evt)) {
|
||||
if (isKeyHotkey('tab', evt)) {
|
||||
evt.preventDefault();
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
export const preventScrollWithArrowKey: KeyboardEventHandler = (evt) => {
|
||||
if (isHotkey(['arrowup', 'arrowright', 'arrowdown', 'arrowleft'], evt)) {
|
||||
if (isKeyHotkey(['arrowup', 'arrowright', 'arrowdown', 'arrowleft'], evt)) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue