Re:Keymaster.js: painless keyboard shortcuts for javascript
by joelhaasnoot on Sunday August 28, 2011 @02:59PM
(#2934637)
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.
(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]=[]),b[a].push({scope:c,method:d,mods:h})})}function h(a){var b=""+a.keyCode;b in c&&(c[b]=!1)}function g(a){var e,f;f=a.target.tagName,e=""+a.keyCode;if(e in c)return c[e]=!0;if(f!="INPUT"&&f!="SELECT"&&f!="TEXTAREA"){if(!(e in b))return;b[e].forEach(function(b){(b.scope==d||b.scope=="all")&&(b.mods.length==0&&!c[16]&&!c[18]&&!c[17]&&!c[91]||b.mods.length>0&&b.mods.every(function(a){return c[a]}))&&b.method(a,b.key,b.scope)===!1&&(a.stopPropagation(),a.preventDefault())})}}var b={},c={16:!1,18:!1,17:!1,91:!1},d="all",e={shift:16,option:18,"⌥":18,alt:18,ctrl:17,control:17,command:91,"⌘":91},f={backspace:8,tab:9,enter:13,"return":13,escape:27,space:32,left:37,up:38,right:39,down:40};document.addEventListener("keydown",g,!1),document.addEventListener("keyup",h,!1),a.key=i,a.keyScope=j})(this)