2018-09-18 06:34:41 +03:00
|
|
|
export default (input: string): string[] => {
|
2020-04-04 02:46:54 +03:00
|
|
|
if (Object.keys(aliases).some(a => a.toLowerCase() === input.toLowerCase())) {
|
2018-09-18 06:34:41 +03:00
|
|
|
const codes = aliases[input];
|
|
|
|
return Array.isArray(codes) ? codes : [codes];
|
|
|
|
} else {
|
|
|
|
return [input];
|
2018-09-17 23:35:06 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const aliases = {
|
2018-09-18 06:34:41 +03:00
|
|
|
'esc': 'Escape',
|
|
|
|
'enter': ['Enter', 'NumpadEnter'],
|
|
|
|
'up': 'ArrowUp',
|
|
|
|
'down': 'ArrowDown',
|
|
|
|
'left': 'ArrowLeft',
|
|
|
|
'right': 'ArrowRight',
|
|
|
|
'plus': ['NumpadAdd', 'Semicolon'],
|
2018-09-17 23:35:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
2022-11-24 10:45:20 +02:00
|
|
|
* Programmatically add the following
|
2018-09-17 23:35:06 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
// lower case chars
|
|
|
|
for (let i = 97; i < 123; i++) {
|
2018-09-18 06:34:41 +03:00
|
|
|
const char = String.fromCharCode(i);
|
|
|
|
aliases[char] = `Key${char.toUpperCase()}`;
|
2018-09-17 23:35:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// numbers
|
2018-09-18 06:34:41 +03:00
|
|
|
for (let i = 0; i < 10; i++) {
|
|
|
|
aliases[i] = [`Numpad${i}`, `Digit${i}`];
|
2018-09-17 23:35:06 +03:00
|
|
|
}
|