open-nomad/ui/app/helpers/clean-keycommand.js
2023-04-10 15:36:59 +00:00

24 lines
478 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
// @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;
});