Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function gatherKeys(event) {
const key = getCode(event);
const mouseButton = getMouseName(event.button);
const primaryEvent = [];
if (isPresent(key)) primaryEvent.push(key);
if (isPresent(mouseButton)) primaryEvent.push(mouseButton)
return ['alt', 'ctrl', 'meta', 'shift'].reduce((keys, keyName) => {
if (event[`${keyName}Key`]) {
keys.push(keyName);
}
return keys;
}, primaryEvent);
}