Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Increase to version 1.1.1

  • Loading branch information...
commit ef865bb8916a11963e58188c8bf782e5f0f7a74a 1 parent d6ae9c4
@ccampbell authored
Showing with 9 additions and 8 deletions.
  1. +1 −1  mousetrap.js
  2. +8 −7 mousetrap.min.js
View
2  mousetrap.js
@@ -16,7 +16,7 @@
* Mousetrap is a simple keyboard shortcut library for Javascript with
* no external dependencies
*
- * @preserve @version 1.1
+ * @preserve @version 1.1.1
* @url craig.is/killing/mice
*/
window.Mousetrap = (function() {
View
15 mousetrap.min.js
@@ -1,7 +1,8 @@
-/* mousetrap v1.1 craig.is/killing/mice */
-window.Mousetrap=function(){function m(a,e,b){if(a.addEventListener)return a.addEventListener(e,b,!1);a.attachEvent("on"+e,b)}function s(a){return"keypress"!=a.type&&h[a.which]?h[a.which]:"keypress"==a.type?String.fromCharCode(a.which):String.fromCharCode(a.which).toLowerCase()}function n(a){var a=a||{},e=!1,b;for(b in i)a[b]?e=!0:i[b]=0;e||(k=!1)}function t(a,e,b,c,z){var g,d,f=[];if(!j[a])return[];"keyup"==b&&o(a)&&(e=[a]);for(g=0;g<j[a].length;++g)if(d=j[a][g],!(d.seq&&i[d.seq]!=d.level)&&b==d.action&&
-("keypress"===b||e.sort().join(",")===d.modifiers.sort().join(",")))c&&d.combo==z&&j[a].splice(g,1),f.push(d);return f}function p(a){a.which="number"==typeof a.which?a.which:a.keyCode;var e=s(a);if(e)if("keyup"===a.type&&q===e)q=!1;else{var b=a.target||a.srcElement,c=b.tagName;if(!(-1<(" "+b.className+" ").indexOf(" mousetrap ")?0:"INPUT"==c||"SELECT"==c||"TEXTAREA"==c)){b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");for(var b=t(e,b,a.type),
-f={},g=!1,c=0;c<b.length;++c)b[c].seq?(g=!0,f[b[c].seq]=1,b[c].callback(a)):!g&&!k&&b[c].callback(a);a.type==k&&!o(e)&&n(f)}}}function o(a){return"shift"==a||"ctrl"==a||"alt"==a||"meta"==a}function u(a,e,b){if(!b){if(!l){l={};for(var c in h)95<c&&112>c||h.hasOwnProperty(c)&&(l[h[c]]=c)}b=l[a]?"keydown":"keypress"}"keypress"===b&&e.length&&(b="keydown");return b}function A(a,e,b,c){i[a]=0;c||(c=u(e[0],[]));var f=function(){k=c;++i[a];clearTimeout(v);v=setTimeout(n,1E3)},g=function(a){b(a);"keyup"!==
-c&&(q=s(a));setTimeout(n,10)},d;for(d=0;d<e.length;++d)w(e[d],d<e.length-1?f:g,c,a,d)}function w(a,e,b,c,f){var a=a.replace(/\s+/g," "),g=a.split(" "),d,h,i=[];if(1<g.length)return A(a,g,e,b);h="+"===a?["+"]:a.split("+");for(g=0;g<h.length;++g)d=h[g],x[d]&&(d=x[d]),b&&("keypress"!=b&&y[d])&&(d=y[d],i.push("shift")),o(d)&&i.push(d);b=u(d,i,b);j[d]||(j[d]=[]);t(d,i,b,!c,a);j[d][c?"unshift":"push"]({callback:e,modifiers:i,action:b,seq:c,level:f,combo:a})}for(var h={8:"backspace",9:"tab",13:"enter",16:"shift",
-17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",46:"del",91:"meta",93:"meta",224:"meta",106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},y={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},x={option:"alt",command:"meta","return":"enter",
-escape:"esc"},l,j={},r={},i={},v,q=!1,k=!1,f=1;20>f;++f)h[111+f]="f"+f;for(f=96;106>f;++f)h[f]=f-96;m(document,"keydown",p);m(document,"keyup",p);m(document,"keypress",p);return{bind:function(a,e,b){for(var c=a instanceof Array?a:[a],f=0;f<c.length;++f)w(c[f],e,b);r[a+":"+b]=e},trigger:function(a,e){r[a+":"+e]()},reset:function(){j={};r={}}}}();
+/* mousetrap v1.1.1 craig.is/killing/mice */
+window.Mousetrap=function(){function o(a,c,b){if(a.addEventListener)return a.addEventListener(c,b,!1);a.attachEvent("on"+c,b)}function u(a){return"keypress"==a.type?String.fromCharCode(a.which):h[a.which]?h[a.which]:v[a.which]?v[a.which]:String.fromCharCode(a.which).toLowerCase()}function p(a){var a=a||{},c=!1,b;for(b in l)a[b]?c=!0:l[b]=0;c||(n=!1)}function w(a,c,b,d,C){var g,e,f=[];if(!j[a])return[];"keyup"==b&&q(a)&&(c=[a]);for(g=0;g<j[a].length;++g)if(e=j[a][g],!(e.seq&&l[e.seq]!=e.level)&&b==
+e.action&&("keypress"===b||c.sort().join(",")===e.modifiers.sort().join(",")))d&&e.combo==C&&j[a].splice(g,1),f.push(e);return f}function r(a,c){!1===a(c)&&(c.preventDefault&&c.preventDefault(),c.stopPropagation&&c.stopPropagation(),c.returnValue=!1,c.cancelBubble=!0)}function s(a){a.which="number"==typeof a.which?a.which:a.keyCode;var c=u(a);if(c)if("keyup"===a.type&&t===c)t=!1;else{var b=a.target||a.srcElement,d=b.tagName;if(!(-1<(" "+b.className+" ").indexOf(" mousetrap ")?0:"INPUT"==d||"SELECT"==
+d||"TEXTAREA"==d)){b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");for(var b=w(c,b,a.type),f={},g=!1,d=0;d<b.length;++d)b[d].seq?(g=!0,f[b[d].seq]=1,r(b[d].callback,a)):!g&&!n&&r(b[d].callback,a);a.type==n&&!q(c)&&p(f)}}}function q(a){return"shift"==a||"ctrl"==a||"alt"==a||"meta"==a}function x(a,c,b){if(!b){if(!k){k={};for(var d in h)95<d&&112>d||h.hasOwnProperty(d)&&(k[h[d]]=d)}b=k[a]?"keydown":"keypress"}"keypress"===b&&c.length&&(b="keydown");
+return b}function y(a,c,b,d,f){var a=a.replace(/\s+/g," "),g=a.split(" "),e,h,i=[];if(1<g.length){var k=a,m=b;l[k]=0;m||(m=x(g[0],[]));a=function(){n=m;++l[k];clearTimeout(z);z=setTimeout(p,1E3)};b=function(a){r(c,a);"keyup"!==m&&(t=u(a));setTimeout(p,10)};for(d=0;d<g.length;++d)y(g[d],d<g.length-1?a:b,m,k,d)}else{h="+"===a?["+"]:a.split("+");for(g=0;g<h.length;++g)e=h[g],A[e]&&(e=A[e]),b&&("keypress"!=b&&B[e])&&(e=B[e],i.push("shift")),q(e)&&i.push(e);b=x(e,i,b);j[e]||(j[e]=[]);w(e,i,b,!d,a);j[e][d?
+"unshift":"push"]({callback:c,modifiers:i,action:b,seq:d,level:f,combo:a})}}for(var h={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},v={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},B={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6",
+"&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},A={option:"alt",command:"meta","return":"enter",escape:"esc"},k,j={},i={},l={},z,t=!1,n=!1,f=1;20>f;++f)h[111+f]="f"+f;for(f=96;106>f;++f)h[f]=f-96;o(document,"keypress",s);o(document,"keydown",s);o(document,"keyup",s);return{bind:function(a,c,b){for(var d=a instanceof Array?a:[a],f=0;f<d.length;++f)y(d[f],c,b);i[a+":"+b]=c},unbind:function(a,c){i[a+":"+c]&&(delete i[a+":"+c],this.bind(a,function(){},c))},
+trigger:function(a,c){i[a+":"+c]()},reset:function(){j={};i={}}}}();

0 comments on commit ef865bb

Please sign in to comment.
Something went wrong with that request. Please try again.