aurelia-contrib / aurelia-combo Goto Github PK
View Code? Open in Web Editor NEWAn Aurelia plugin for easy keyboard combo short-cuts
License: MIT License
An Aurelia plugin for easy keyboard combo short-cuts
License: MIT License
In index.d.ts
, the combo()
function defines shortcuts
as string[]
. Now that we've made implemented #1 , We'll need to update the TypeScript definition to allow (string|boolean)[]
.
I didn't catch this until this morning when I updated my TS codebase to the new version. D'oh!
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!
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.