Live data from Hacker News

Keymaster.js: painless keyboard shortcuts for javascript

github.com

11–20 of 23 posts

Re: Keymaster.js: painless keyboard shortcuts for javascript

#11
post #6

Hmm. Binds all events to `document`, which means that if you type something in a text field, it'll still trigger the event. (One of the TODOs is "Make behavior with INPUT / SELECT / TEXTAREA configurable.) Thing is, jQuery Hotkeys ( https://github.com/jeresig/jquery.hotkeys ) is more versatile (since you can bind events to any element), works under a wider range of browsers, and is nearly as lightweight (if you alrea…

It doesn't trigger events if you're in a INPUT/TEXTAREA/SELECT. The todo refers to making this configurable in a per-shortcut fashion.

Ah, my bad. I didn't catch the line "if (tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA') return;", which is indeed a sensible default.

Re: Keymaster.js: painless keyboard shortcuts for javascript

#12
Look, github is great and all, but will linking to your github repo really entice me to use your library? If its brownie points you're looking for in using github, you lost them by not providing a demo of the library and only a tiny bit of code that explains what it does.

Re: Keymaster.js: painless keyboard shortcuts for javascript

#13
post #5
post #4

Why would you store a minified version in the VCS, especially not having it in sync with the original source code? Shouldn't it be an artefact kept out of the VCS and built automatically by, for example, make and UglifyJS?

It's more convenient with a minified source layoung around somewhere. Also it's quite small: (function(a){function j(a){d=a||"all"}function i(a,c,d){var g,h;d===undefined&&(d=c,c="all"),a=a.replace(/\s/g,""),g=a.split(","),g.forEach(function(a){h=[],a=a.split("+"),a.length>1&&(h=a.slice(0,a.length-1).map(function(a){return e[a]}),a=[a[a.length-1]]),a=a[0],a=a.length>1?f[a]:a.toUpperCase().charCodeAt(0),a in b||(b[a]=…

By putting the source on github you're inviting people to use your code in their projects, and pick it apart. It's next to impossible to pick apart like this. In addition, a minified version is a build product, which you don't put in a VCS. Offer the minified version as a download, that's what that feature is there for.

Re: Keymaster.js: painless keyboard shortcuts for javascript

#14
post #12

Look, github is great and all, but will linking to your github repo really entice me to use your library? If its brownie points you're looking for in using github, you lost them by not providing a demo of the library and only a tiny bit of code that explains what it does.

+1 - I hate getting linked to GitHub repos where the "demo" is download, install, and then copy and paste this demo code.

Re: Keymaster.js: painless keyboard shortcuts for javascript

#15
post #12

Look, github is great and all, but will linking to your github repo really entice me to use your library? If its brownie points you're looking for in using github, you lost them by not providing a demo of the library and only a tiny bit of code that explains what it does.

One of things I like about github is that it's done a great job of enticing developers to write good README files. I've seen many projects that do a fine job of introducing the project, listing things like license, dependencies, etc., and showing example code of how it works. Often times it also links to a demo or screencasts. For most projects, this seems good enough -- most project web sites don't add any more value.

Re: Keymaster.js: painless keyboard shortcuts for javascript

#17
post #5

Earlier quoted context omitted.

It's more convenient with a minified source layoung around somewhere. Also it's quite small: (function(a){function j(a){d=a||"all"}function i(a,c,d){var g,h;d===undefined&&(d=c,c="all"),a=a.replace(/\s/g,""),g=a.split(","),g.forEach(function(a){h=[],a=a.split("+"),a.length>1&&(h=a.slice(0,a.length-1).map(function(a){return e[a]}),a=[a[a.length-1]]),a=a[0],a=a.length>1?f[a]:a.toUpperCase().charCodeAt(0),a in b||(b[a]=…

By putting the source on github you're inviting people to use your code in their projects, and pick it apart. It's next to impossible to pick apart like this. In addition, a minified version is a build product, which you don't put in a VCS. Offer the minified version as a download, that's what that feature is there for.

Putting build artifacts in source control does seem a bit strange. Nevertheless, it's very common practice with JavaScript libraries.

Re: Keymaster.js: painless keyboard shortcuts for javascript

#18
I like the fact that this library has no dependencies. I suggest that the _MAP variable in keymaster.js should be equal to the specialKeys variable defined in jquery.hotkeys.js.

https://github.com/jeresig/jquery.hotkeys/blob/master/jquery...

in order to cover all special keys.

Post reply on HN