How to use ember-keyboard - 10 common examples

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 / 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 / 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;
    }
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 / 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 linxmix / linx / app / components / mix-builder.js View on Github external
// optional params
  selectedTransition: null,
  selectedClip: null,

  // params
  selectedQuantizations: [BAR_QUANTIZATION],
  selectedQuantization: Ember.computed.reads('selectedQuantizations.firstObject'),
  mixVisualActionReceiver: null,
  store: Ember.inject.service(),

  followPlayhead: false,
  selectedAutomation: CONTROL_TYPE_VOLUME,
  newTrackPosition: null,

  _playpauseMix: Ember.on(keyDown('Space'), makeKeybinding(function(e) {
    this.send('playpause');
  })),

  _exitTransitionOnEscape: Ember.on(keyDown('Escape'), makeKeybinding(function(e) {
    this.send('selectTransition', null);
  })),

  _pauseMix: Ember.on('willDestroyElement', function() {
    this.send('pause');
  }),

  // repeatedely save mix, if any unsaved changes
  // _autoSaveMix: Ember.on('init', function() {
  //   if (!this.get('isDestroyed')) {
  //     const mix = this.get('mix');
github ember-learn / ember-cli-addon-docs / addon / components / docs-header / search-results / component.js View on Github external
})

        // Add a reference to the Ember Data model to each API item search result
        .map(searchResult => {
          let { document } = searchResult;
          if (document.type !== 'template') {
            let store = this.get('store');
            searchResult.model = store.peekRecord(document.type, document.item.id)
          }

          return searchResult;
        });
    }
  }),

  gotoSelectedItem: on(keyUp('Enter'), function() {
    if (this.get('selectedIndex') !== null) {
      let selectedResult = this.get('searchResults')[this.get('selectedIndex')];
      if (selectedResult.document.type === 'template') {
        this.get('router').transitionTo(selectedResult.document.route);
      } else {
        this.get('router').transitionTo('docs.api.item', selectedResult.model.get('routingId'));
      }
    }

    this.get('on-visit')();
  }),

  nextSearchResult: on(keyDown('ctrl+KeyN'), keyDown('ArrowDown'), function() {
    let hasSearchResults = this.get('searchResults.length');
    let lastResultIsSelected = (this.get('selectedIndex') + 1 === this.get('searchResults.length'));
github ember-learn / ember-cli-addon-docs / addon / components / docs-header / search-box / component.js View on Github external
didInsertElement() {
    this._super();

    this.get('fetchProject').perform();
  },

  // TODO: The searchbox doesn't work without the project being fetched.
  // We should move this logic (and everywhere else in the code that's fetching
  // the project) within a new addonDocs service that wires all that up together.
  // I think it's fine if our Docs-* components assume there is a single global
  // project.
  fetchProject: task(function*() {
    yield this.get('store').findRecord('project', projectName);
  }),

  focusSearch: on(keyUp('Slash'), function() {
    if (!formElementHasFocus()) {
      this.element.querySelector('input').focus();
    }
  }),

  unfocusSearch: on(keyUp('Escape'), function() {
    this.get('on-input')(null);
  })
});
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 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;
  }, {});