feat: Allow users to select Cmd+Enter
as a hotkey (#4401)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
parent
9ea43a2678
commit
beedfc47bf
14 changed files with 344 additions and 93 deletions
|
@ -10,6 +10,10 @@ export const hasPressedShift = e => {
|
|||
return e.shiftKey;
|
||||
};
|
||||
|
||||
export const hasPressedCommand = e => {
|
||||
return e.metaKey;
|
||||
};
|
||||
|
||||
export const hasPressedCommandAndEnter = e => {
|
||||
return e.metaKey && e.keyCode === 13;
|
||||
};
|
||||
|
@ -89,3 +93,25 @@ export const hasPressedArrowDownKey = e => {
|
|||
export const hasPressedCommandPlusKKey = e => {
|
||||
return e.metaKey && e.keyCode === 75;
|
||||
};
|
||||
|
||||
export const buildHotKeys = e => {
|
||||
const key = e.key.toLowerCase();
|
||||
if (['shift', 'meta', 'alt', 'control'].includes(key)) {
|
||||
return key;
|
||||
}
|
||||
let hotKeyPattern = '';
|
||||
if (e.altKey) {
|
||||
hotKeyPattern += 'alt+';
|
||||
}
|
||||
if (e.ctrlKey) {
|
||||
hotKeyPattern += 'ctrl+';
|
||||
}
|
||||
if (e.metaKey && !e.ctrlKey) {
|
||||
hotKeyPattern += 'meta+';
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
hotKeyPattern += 'shift+';
|
||||
}
|
||||
hotKeyPattern += key;
|
||||
return hotKeyPattern;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue