dmauro / Keypress

A keyboard input capturing utility in which any key can be a modifier key.
http://dmauro.github.io/Keypress/
Apache License 2.0
3.18k stars 313 forks source link

More node-ish require support #87

Open maxkorp opened 9 years ago

maxkorp commented 9 years ago

I know the module works with require, but do you have any thoughts on supporting node style require over just commonjs? Currently, works like so

var x = require('keypress.js') // from NPM module, it's published as keypress.js instead of keypres
x.keypress // The module

Whats more typical for node modules is like so

var x = require('keypress.js');
x; // The module

In my experience just from browsing through other projects, it seems that people give prevalence to module.exports if it's available, and fall back to just exports when thats available. If that's a palatable solution, I'd be happy to submit a PR. This is hardly a breaking thing either way, just a nice convenience bit.

Alternatively, I could convert it to UMD.

Either way, it's a breaking change by default (since anybody in a node environment would be expecting requiredvar.keypress, not just requiredvar. We could also shortcut that though, so it would continue working.

dmauro commented 9 years ago

Sorry for the super late response. If you'd like to submit a PR that would be great. It sounds like you know more about this particular case than I do.