How to use the ember-keyboard.getKeyCode 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-test-support / key-event.js View on Github external
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;
    }

    return event;
  }, {});
github briarsweetbriar / ember-keyboard / test-support / helpers / ember-keyboard / register-test-helpers.js View on Github external
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;
  }, {});
github affinity-engine / affinity-engine / test-support / helpers / ember-theater / director / step.js View on Github external
export default function(app, duration) {
  const keyCode = getKeyCode('F3');

  triggerEvent(document, 'keyup', {
    keyCode,
    which: keyCode,
    altKey: true,
    ctrlKey: true,
    shiftKey: true
  });

  return delay(duration);
}
github briarsweetbriar / ember-keyboard / addon / utils / trigger-event.js View on Github external
const triggerKeyEvent = function triggerKeyEvent(eventType, rawCode, element) {
  const event = new Event(eventType);
  const parts = rawCode.split('+');
  const [code] = parts.filter((part) => !validModifiers.includes(part));
  const modifiers = parts.filter((part) => part !== code);
  const properties = modifiers.reduce((properties, modifier) => {
    modifier = modifier === 'cmd' ? getCmdKey() : modifier;
    properties[`${modifier}Key`] = true;

    return properties;
  }, {});

  assign(event, { code, keyCode: getKeyCode(code) }, properties);

  (element || document).dispatchEvent(event);
};