How to use the ember-keyboard/utils/get-code function in ember-keyboard

To help you get started, we’ve selected a few ember-keyboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github briarsweetbriar / ember-keyboard / addon / utils / handle-key-event.js View on Github external
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);
}