Is it somehow possible to assign this function not to the variable name shortcut
but to the content of it?
if (this.commands[this.counter].shortcut) {
const shortcut = this.commands[this.counter].shortcut;
tinykeys(window, {
shortcut: (event) => {
this.followLink('https://twitter.com');
},
});
}
For example: The value of shortcut
could be a String with value 'abc' and I want to get the following result:
tinykeys(window, {
'abc': (event) => {
this.followLink('https://twitter.com');
},
});
You can use a computed property name.
[shortcut]: (event) => {
this.followLink('https://twitter.com');
},