Advertisement
Guest User

getPressedKey

a guest
Jun 30th, 2015
1,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getPressedKey (event) {
  2.         var out, ex = event.keyCode || event.which;
  3.         var
  4.             // Letters
  5.                 a=65,
  6.                 b=66,
  7.                 c=67,
  8.                 d=68,
  9.                 e=69,
  10.                 f=70,
  11.                 g=71,
  12.                 h=72,
  13.                 i=73,
  14.                 j=74,
  15.                 k=75,
  16.                 l=76,
  17.                 m=77,
  18.                 n=78,
  19.                 o=79,
  20.                 p=80,
  21.                 q=81,
  22.                 r=82,
  23.                 s=83,
  24.                 t=84,
  25.                 u=85,
  26.                 v=86,
  27.                 w=87,
  28.                 x=88,
  29.                 y=89,
  30.                 z=90,
  31.                 space=32,
  32.             // Others
  33.                 ctrl=17,
  34.                 bs=8,
  35.                 enter=13,
  36.                 shift=16,
  37.                 alt=18,
  38.                 pause=19,
  39.                 caps=20,
  40.                 esc=27,
  41.                 pageup=33,
  42.                 pagedown=34,
  43.                 end=35,
  44.                 home=36,
  45.                 leftarrow=37,
  46.                 uparrow=38,
  47.                 downarrow=40,
  48.                 insert=45,
  49.                 del=46,
  50.                 winleft=91,
  51.                 winright=92,
  52.                 select=93,
  53.             // Numbers
  54.                 // Normal
  55.                     zero=48,
  56.                     one=49,
  57.                     two=50,
  58.                     three=51,
  59.                     four=52,
  60.                     five=53,
  61.                     six=54,
  62.                     seven=55,
  63.                     eight=56,
  64.                     nine=57,
  65.                 // Numpad
  66.                     num0=96,
  67.                     num1=97,
  68.                     num2=98,
  69.                     num3=99,
  70.                     num4=100,
  71.                     num5=101,
  72.                     num6=102,
  73.                     num7=103,
  74.                     num8=104,
  75.                     num9=105,
  76.             // Equations
  77.                 times=106,
  78.                 add=107,
  79.                 minus=109,
  80.                 decimal=110,
  81.                 devide=111,
  82.             // Functions
  83.                 f1=112,
  84.                 f2=113,
  85.                 f3=114,
  86.                 f4=115,
  87.                 f5=116,
  88.                 f6=117,
  89.                 f7=118,
  90.                 f8=119,
  91.                 f9=120,
  92.                 f10=121,
  93.                 f11=122,
  94.                 f12=123,
  95.             // Others 2
  96.                 numlock=114,
  97.                 scrolllock=145,
  98.                 semicolon=186,
  99.                 equals=187,
  100.                 comma=188,
  101.                 dash=189,
  102.                 period=190,
  103.                 slash=191,
  104.                 grave=192,
  105.                 openbracket=219,
  106.                 backslash=220,
  107.                 closebracket=221,
  108.                 singlequote=222;
  109.  
  110.         // Others
  111.             if (ex==numlock) out = "numlock";
  112.             if (ex==scrolllock) out = "scrolllock";
  113.             if (ex==semicolon) out = "semicolon";
  114.             if (ex==equals) out = "equals";
  115.             if (ex==comma) out = "comma";
  116.             if (ex==dash) out = "dash";
  117.             if (ex==period) out = "period";
  118.             if (ex==slash) out = "slash";
  119.             if (ex==grave) out = "grave";
  120.             if (ex==openbracket) out = "openbracket";
  121.             if (ex==backslash) out = "backslash";
  122.             if (ex==closebracket) out = "closebracket";
  123.             if (ex==singlequote) out = "singlequote";
  124.             if (ex==ctrl) out = "ctrl";
  125.             if (ex==bs) out = "backspace";
  126.             if (ex==enter) out = "enter";
  127.             if (ex==shift) out = "shift";
  128.             if (ex==alt) out = "alt";
  129.             if (ex==pause) out = "pause";
  130.             if (ex==caps) out = "caps";
  131.             if (ex==esc) out = "esc";
  132.             if (ex==pageup) out = "pageup";
  133.             if (ex==pagedown) out = "padedown";
  134.             if (ex==end) out = "end";
  135.             if (ex==home) out = "home";
  136.             if (ex==leftarrow) out = "leftarrow";
  137.             if (ex==uparrow) out = "uparrow";
  138.             if (ex==downarrow) out = "downarrow";
  139.             if (ex==insert) out = "insert";
  140.             if (ex==del) out = "delete";
  141.             if (ex==winleft) out = "winleft";
  142.             if (ex==winright) out = "winright";
  143.             if (ex==select) out = "select";
  144.         // Numbers
  145.             // Normal
  146.                 if (ex==one) out = 1;
  147.                 if (ex==two) out = 2;
  148.                 if (ex==three) out = 3;
  149.                 if (ex==four) out = 4;
  150.                 if (ex==five) out = 5;
  151.                 if (ex==six) out = 6;
  152.                 if (ex==seven) out = 7;
  153.                 if (ex==eight) out = 8;
  154.                 if (ex==nine) out = 9;
  155.                 if (ex==zero) out = 0;
  156.             // Numpad
  157.                 if (ex==num1) out = 1;
  158.                 if (ex==num2) out = 2;
  159.                 if (ex==num3) out = 3;
  160.                 if (ex==num4) out = 4;
  161.                 if (ex==num5) out = 5;
  162.                 if (ex==num6) out = 6;
  163.                 if (ex==num7) out = 7;
  164.                 if (ex==num8) out = 8;
  165.                 if (ex==num9) out = 9;
  166.                 if (ex==num0) out = 0;
  167.         // Equations
  168.             if (ex==times) out = "times";
  169.             if (ex==add) out = "add";
  170.             if (ex==minus) out = "minus";
  171.             if (ex==decimal) out = "decimal";
  172.             if (ex==devide) out = "devide";
  173.         // Functions
  174.             if (ex==f1) out = "f1";
  175.             if (ex==f2) out = "f2";
  176.             if (ex==f3) out = "f3";
  177.             if (ex==f4) out = "f4";
  178.             if (ex==f5) out = "f5";
  179.             if (ex==f6) out = "f6";
  180.             if (ex==f7) out = "f7";
  181.             if (ex==f8) out = "f8";
  182.             if (ex==f9) out = "f9";
  183.             if (ex==f10) out = "f10";
  184.             if (ex==f11) out = "f11";
  185.             if (ex==f12) out = "f12";
  186.         // Letters
  187.             if (ex==a) out = "a";
  188.             if (ex==b) out = "b";
  189.             if (ex==c) out = "c";
  190.             if (ex==d) out = "d";
  191.             if (ex==e) out = "e";
  192.             if (ex==f) out = "f";
  193.             if (ex==g) out = "g";
  194.             if (ex==h) out = "h";
  195.             if (ex==i) out = "i";
  196.             if (ex==j) out = "j";
  197.             if (ex==k) out = "k";
  198.             if (ex==l) out = "l";
  199.             if (ex==m) out = "m";
  200.             if (ex==n) out = "n";
  201.             if (ex==o) out = "o";
  202.             if (ex==p) out = "p";
  203.             if (ex==q) out = "q";
  204.             if (ex==r) out = "r";
  205.             if (ex==s) out = "s";
  206.             if (ex==t) out = "t";
  207.             if (ex==u) out = "u";
  208.             if (ex==v) out = "v";
  209.             if (ex==w) out = "w";
  210.             if (ex==x) out = "x";
  211.             if (ex==y) out = "y";
  212.             if (ex==z) out = "z";
  213.             if (ex==space) out = "space";
  214.  
  215.         return out;
  216.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement