55
66"use strict"
77var key_code_value = {
8- "112" : "F1" ,
9- "113" : "F2" ,
10- "114" : "F3" ,
11- "115" : "F4" ,
12- "116" : "F5" ,
13- "117" : "F6" ,
14- "118" : "F7" ,
15- "119" : "F8" ,
16- "120" : "F9" ,
17- "121" : "F10" ,
18- "122" : "F11" ,
19- "123" : "F12" ,
20- "91" : "Windows" ,
21- "32" : "Space" ,
22- "27" : "Esc" ,
23- "8" : "Backspace" ,
24- "189" : "Dash" ,
25- "187" : "Equal" ,
26- "220" : "Back slash" ,
27- "13" : "Enter" ,
28- "222" : "single quote" ,
29- "186" : "Semi colon" ,
30- "190" : "Period/Dot" ,
31- "191" : "Forward slash" ,
32- "188" : "Comma" ,
33- "16" : "Shift" ,
34- "20" : "caps lock" ,
35- "9" : "Tab" ,
36- "192" : "grave accent" ,
37- "17" : "ctrl" ,
38- "18" : "alt" ,
39- "93" : "Windows menu" ,
40- "37" : "Left Arrow" ,
41- "38" : "Up Arrow" ,
42- "39" : "Right Arrow" ,
43- "40" : "Down Arrow" ,
44- "45" : "Insert" ,
45- "46" : "Delete" ,
46- "33" : "Page Up" ,
47- "34" : "Page Down" ,
48- "35" : "End" ,
49- "36" : "Home" ,
50- "144" : "Num lock" ,
51- "111" : "Divide" ,
52- "106" : "Multiply" ,
53- "109" : "Subtract" ,
54- "107" : "add" ,
55- "12" : "Clear" ,
56- "219" : "Open bracket " ,
57- "221" : "Close bracket"
58-
59-
60-
8+ "112" : "F1" ,
9+ "113" : "F2" ,
10+ "114" : "F3" ,
11+ "115" : "F4" ,
12+ "116" : "F5" ,
13+ "117" : "F6" ,
14+ "118" : "F7" ,
15+ "119" : "F8" ,
16+ "120" : "F9" ,
17+ "121" : "F10" ,
18+ "122" : "F11" ,
19+ "123" : "F12" ,
20+ "91" : "Windows" ,
21+ "32" : "Space" ,
22+ "27" : "Esc" ,
23+ "8" : "Backspace" ,
24+ "189" : "Dash" ,
25+ "187" : "Equal" ,
26+ "220" : "Back slash" ,
27+ "13" : "Enter" ,
28+ "222" : "single quote" ,
29+ "186" : "Semi colon" ,
30+ "190" : "Period/Dot" ,
31+ "191" : "Forward slash" ,
32+ "188" : "Comma" ,
33+ "16" : "Shift" ,
34+ "20" : "caps lock" ,
35+ "9" : "Tab" ,
36+ "192" : "grave accent" ,
37+ "17" : "ctrl" ,
38+ "18" : "alt" ,
39+ "93" : "Windows menu" ,
40+ "37" : "Left Arrow" ,
41+ "38" : "Up Arrow" ,
42+ "39" : "Right Arrow" ,
43+ "40" : "Down Arrow" ,
44+ "45" : "Insert" ,
45+ "46" : "Delete" ,
46+ "33" : "Page Up" ,
47+ "34" : "Page Down" ,
48+ "35" : "End" ,
49+ "36" : "Home" ,
50+ "144" : "Num lock" ,
51+ "111" : "Divide" ,
52+ "106" : "Multiply" ,
53+ "109" : "Subtract" ,
54+ "107" : "add" ,
55+ "12" : "Clear" ,
56+ "219" : "Open bracket " ,
57+ "221" : "Close bracket"
6158} ;
59+
6260var displaykeycode = rao ( '#keycode' ) ;
6361var displaykeychar = rao ( '#keychar' ) ;
64- document . addEventListener ( "keydown" , function ( e ) {
62+ document . addEventListener ( "keydown" , function ( e ) {
6563 var keynum ;
6664 if ( window . event ) {
67- keynum = e . keyCode ;
68- } else if ( e . which ) {
69- keynum = e . which ;
70- }
71- var keychar = String . fromCharCode ( keynum ) ;
72- if ( key_code_value [ keynum ] ) {
73- keychar = key_code_value [ keynum ] ;
74- e . preventDefault ( ) ;
75- }
65+ keynum = e . keyCode ;
66+ } else if ( e . which ) {
67+ keynum = e . which ;
68+ }
69+ var keychar = String . fromCharCode ( keynum ) ;
70+ if ( key_code_value [ keynum ] ) {
71+ keychar = key_code_value [ keynum ] ;
72+ e . preventDefault ( ) ;
73+ }
7674 displaykeycode . text ( keynum ) ;
7775 displaykeychar . text ( keychar ) ;
7876
79- if ( keynum => 65 && keynum <= 90 ) {
80- displaykeycode . attri ( "class" , " " ) ;
81- displaykeycode . attri ( "class" , "redcolor" ) ;
82- } else {
83- displaykeycode . attri ( "class" , " " ) ;
84- displaykeycode . attri ( "class" , "greencolor" ) ;
77+ if ( keynum => 65 && keynum <= 90 ) {
78+ displaykeycode . attri ( "class" , " " ) ;
79+ displaykeycode . attri ( "class" , "redcolor" ) ;
80+ } else {
81+ displaykeycode . attri ( "class" , " " ) ;
82+ displaykeycode . attri ( "class" , "greencolor" ) ;
8583 }
8684
87-
88- // prevent
89- if ( ( keynum === 83 || keynum === 68 || keynum === 65 ) && e . ctrlKey ) {
90- e . preventDefault ( ) ;
91- return false ;
85+ trackUserAction ( e , keynum ) ;
86+ // prevent
87+ if ( e . ctrlKey && ( keynum === 83 || keynum === 68 || keynum === 65 ) ) {
88+ // e.preventDefault();
89+ // return false;
9290 }
9391} ) ;
9492
9593// for ticker
96- var initial_width = 10 ;
97- var docwidth = window . innerWidth || document . documentElement . clientWidth || document . body . clientWidth ;
94+ // var initial_width = 10;
95+ // var docwidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
96+
97+ // function increment() {
98+ // initial_width += 2;
99+ // if (initial_width + 50 >= docwidth) {
100+ // clearInterval(d);
101+ // }
102+ // document.getElementById("myprofile").style.width = initial_width + "px";
103+ // }
104+
105+ // var d = setInterval("increment()", 10);
106+
98107
99- function increment ( ) {
100- initial_width += 2 ;
101- if ( initial_width + 50 >= docwidth ) {
102- clearInterval ( d ) ;
108+ var str_arr = 'Press Any key →' . split ( '' ) ;
109+ var str_index = 0 ;
110+ var temp_str = '' ;
111+ function typing ( ) {
112+ if ( str_index === str_arr . length - 1 ) {
113+ clearInterval ( kk ) ;
103114 }
104- document . getElementById ( "myprofile" ) . style . width = initial_width + "px" ;
115+ temp_str += str_arr [ str_index ] ;
116+ rao ( '#welcome' ) . text ( temp_str + "|" ) ;
117+ str_index ++ ;
105118}
106119
107- var d = setInterval ( "increment ()" , 10 ) ;
120+ var kk = setInterval ( "typing ()" , 500 ) ;
0 commit comments