Files
nomad/ui/app/helpers/clean-keycommand.js
2023-08-10 17:27:29 -05:00

24 lines
479 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
// @ts-check
import { helper } from '@ember/component/helper';
const KEY_ALIAS_MAP = {
ArrowRight: '→',
ArrowLeft: '←',
ArrowUp: '↑',
ArrowDown: '↓',
'+': ' + ',
};
export default helper(function cleanKeycommand([key] /*, named*/) {
let cleaned = key;
Object.keys(KEY_ALIAS_MAP).forEach((k) => {
cleaned = cleaned.replace(k, KEY_ALIAS_MAP[k]);
});
return cleaned;
});