mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
Fix #2195: normalizing keybindings using localeCompare to include non english keyboards as well
34 lines
671 B
JavaScript
34 lines
671 B
JavaScript
import {remote} from 'electron';
|
|
|
|
const getCommand = remote.require('./utils/keymaps/get-command');
|
|
|
|
export default function returnKey(e) {
|
|
let keys = [];
|
|
|
|
if (e.metaKey && process.platform === 'darwin') {
|
|
keys.push('cmd');
|
|
} else if (e.metaKey) {
|
|
keys.push(e.key);
|
|
}
|
|
|
|
if (e.ctrlKey) {
|
|
keys.push('ctrl');
|
|
}
|
|
|
|
if (e.shiftKey) {
|
|
keys.push('shift');
|
|
}
|
|
|
|
if (e.altKey) {
|
|
keys.push('alt');
|
|
}
|
|
|
|
if (e.key === ' ') {
|
|
keys.push('space');
|
|
} else if (e.key !== 'Meta' && e.key !== 'Control' && e.key !== 'Shift' && e.key !== 'Alt') {
|
|
keys.push(e.key.replace('Arrow', ''));
|
|
}
|
|
|
|
keys = keys.join('+');
|
|
return getCommand(keys);
|
|
}
|