philipjscott / key-controller Goto Github PK
View Code? Open in Web Editor NEWkeydown and keyup handlers without headaches! :tada:
Home Page: https://www.npmjs.com/package/key-controller
License: MIT License
keydown and keyup handlers without headaches! :tada:
Home Page: https://www.npmjs.com/package/key-controller
License: MIT License
The library is broken ๐ข
What happened:
The following snippet does not work:
const controls = {
inc: 'alt+b'
}
What you expected to happen:
Virtual keys should be able to map to compound keybindings
ES6
transpilers ATMimport
syntaxkeycode
)Webpack 4 seems like a good candidate for building
Users should not need to need to manually check e.shiftKey
; they should be able to put case-sensitive characters in the controls.
Describe the bug
The karma configuration is overly complicated (need to do a babel transform, then a browserify transform, then hook it up to istanbul). Not only that, but there's some buggy behaviour when running the tests in headless chrome (eg. https://github.com/ScottyFillups/key-controller/blob/master/test/controller.test.js#L28).
However, the most jarring problem is that the coverage reports returned from karma don't make any sense; why is it complaining that comments aren't being hit (https://coveralls.io/builds/19758335/source?filename=lib/controller.js)? Perhaps it would make more sense to just mock out the DOM and use Ava?
Users should be able to two or more real keys to a single virtual key. Perhaps by passing in an array such as left: ['left', 'a']
.
Describe the bug
The README concepts section is too wordy, and the usage section's example is too large in scope.
Expected behavior
The usage and concepts section should be simple, and you should go more in-depth in an API section.
Consider:
const virtuals = (obj1, obj2, e) => ({
next () {
obj1.foo()
},
bar: {
keyup () {
obj2.bar()
},
keydown () {
obj1.eee(e)
}
}
})
export default virtuals
If a virtual is a function rather than an object containing keyup
and/or keydown
, then it's assumed that the function should be applied on keydown
(a shorthand). Multiple models will be allowed, and the keyboard event
will be passed as the last parameter.
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.