hippofish/packages/frontend/src/scripts/keycode.ts

24 lines
551 B
TypeScript
Raw Normal View History

/*
2024-02-12 03:37:45 +01:00
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
2018-09-18 05:34:41 +02:00
export default (input: string): string[] => {
2020-04-04 01:46:54 +02:00
if (Object.keys(aliases).some(a => a.toLowerCase() === input.toLowerCase())) {
2018-09-18 05:34:41 +02:00
const codes = aliases[input];
return Array.isArray(codes) ? codes : [codes];
} else {
return [input];
}
};
export const aliases = {
2018-09-18 05:34:41 +02:00
'esc': 'Escape',
'enter': ['Enter', 'NumpadEnter'],
'up': 'ArrowUp',
'down': 'ArrowDown',
'left': 'ArrowLeft',
'right': 'ArrowRight',
'plus': ['NumpadAdd', 'Semicolon'],
};