GithubHelp home page GithubHelp logo

aurelia-combo's People

Contributors

3cp avatar zshall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zshall

aurelia-combo's Issues

Allow shortcuts to work inside input fields with flag

A common use case for keyboard shortcuts is to work while input or textarea elements are focused. Keymaster's default filter excludes these elements when firing shortcuts.

Searching around the Keymaster repo, I've found a few pages discussing this:

https://github.com/madrobby/keymaster#filter-key-presses
madrobby/keymaster#43
madrobby/keymaster#165

Issue 43 is closest to what I was thinking about. You'd have a flag, such as @combo("shortcut", true). When this is set, the shortcut would run anywhere, including inputs. If the flag wasn't set, the shortcut would be filtered out of inputs using the default filter.

Another idea would be to support custom filtering functions. Imagine something like @combo('shortcuts', this.filter) where this.filter is a function in the current class that would only trigger the keyboard shortcut if it returned true.

I'd be willing to help tackle this, but I'd like to figure out the best way before going about it.

One approach would be to override Keymaster's built-in filtering with a new filtering system.

key.filter = (ev) => {
    return true;
}

Disabling the regular filter, and when registering a shortcut, doing the equivalent of this:

  [where the plugin is called]() {
    key('ctrl+f, command+f', e => {
      if (flag || (!flag && [we're not in an input or textarea)]) {
        if (true !== this.findIt(e)) e.preventDefault();
      }
    })
  }

  @combo('ctrl+f, command+f', true)
  findIt(e) {
    console.log('findIt');
  }

Any additional thoughts would be appreciated!

TODO: should not skip filter on focused button

When user use @combo('ctrl+f', true) to turn on combo inside input/select/textarea, the filter on focused button should not be skipped.

Need to seperate the input/select/textarea filter and the focused button filter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.