Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const event = keys.reduce((event, attribute) => {
const isValidModifier = validModifiers.indexOf(attribute) > -1;
if (isValidModifier) {
attribute = attribute === 'cmd' ? getCmdKey() : attribute;
event[`${attribute}Key`] = true;
} else if (validMouseButtons.indexOf(attribute) > -1) {
event.button = getMouseCode(attribute);
} else {
const keyCode = getKeyCode(attribute);
event.code = attribute;
// deprecated / removed from the Web Standards
event.which = keyCode;
event.keyCode = keyCode;
}
const event = (attributes || '').split('+').reduce((event, attribute) => {
if (validModifiers.indexOf(attribute) > -1) {
attribute = attribute === 'cmd' ? getCmdKey() : attribute;
event[`${attribute}Key`] = true;
} else if (validMouseButtons.indexOf(attribute) > -1) {
event.button = getMouseCode(attribute);
} else {
event.keyCode = getKeyCode(attribute);
}
return event;
}, {});