Keycodes in javascript

0.42K views
no comments
20 Sep 2015 3:34 pm

I have defined variables of keycodes from laptop keyboard, copy codes and use in your code line, and defined for developer and designer to easily use  who don’t want to know the keyCode.

Minified variables

 var escape=27,f1=112,f2=113,f3=114,f4=115,f5=116,f6=117,f7=118,f8=119,f9=120,f10=121,f11=122,f12=123,print_sc=44,insert=45,del=46,home=36,end=35,pgup=33,pgdn=34,backticks=192,key_1=49,key_2=50,key_3=51,key_4=52,key_5=53,key_6=54,key_7=55,key_8=56,key_9=57,key_0=48,minus=189,plus=187,backspace=8,tab=9,q=81,w=87,e=69,r=82,t=84,y=89,u=85,i=73,o=79,p=80,bracketleft=219,bracketright=221,backslash=220,caps=20,a=65,s=83,d=68,f=70,g=71,h=72,j=74,k=75,l=76,coln=186,quotes=222,enter=13,shift=16,z=90,x=88,c=67,v=86,b=66,n=78,m=77,comma=188,dot=190,slash=191,ctrl=17,start=91,alt=18,space=32,leftarrow=37,toparrow=38,rightarrow=39,downarrow=40,numlock=144,numpadslash=111,numasterisk=106,numminus=109,numplus=107,numdot=110,num0=96,num1=97,num2=98,num3=99,num4=100,num5=101,num6=102,num7=103,num8=104,num9=105;

First define variables

var escape=27;
var f1=112;
var f2=113;
var f3=114;
var f4=115;
var f5=116;
var f6=117;
var f7=118;
var f8=119;
var f9=120;
var f10=121;
var f11=122;
var f12=123;
var print_sc=44;
var insert=45;
var del=46;
var home=36;
var end=35;
var pgup=33;
var pgdn=34
var backticks=192;
var key_1=49;
var key_2=50;
var key_3=51;
var key_4=52;
var key_5=53;
var key_6=54;
var key_7=55;
var key_8=56;
var key_9=57;
var key_0=48;
var minus=189;
var plus=187;
var backspace=8;
var tab=9;
var q=81;
var w=87;
var e=69;
var r=82;
var t=84;
var y=89;
var u=85;
var i=73;
var o=79;
var p=80;
var bracketleft=219;
var bracketright=221;
var backslash=220;
var caps=20;
var a=65;
var s=83;
var d=68;
var f=70;
var g=71;
var h=72;
var j=74;
var k=75;
var l=76;
var coln=186;
var quotes=222;
var enter=13;
var shift=16;
var z=90;
var x=88;
var c=67;
var v=86;
var b=66;
var n=78;
var m=77;
var comma=188;
var dot=190;
var slash=191;
var ctrl=17;
var start=91;
var alt=18;
var space=32;
var leftarrow=37;
var toparrow=38;
var rightarrow=39;
var downarrow=40;
var numlock=144;
var numpadslash=111;
var numasterisk=106;
var numminus=109;
var numplus=107;
var numdot=110;
var num0=96;
var num1=97;
var num2=98;
var num3=99;
var num4=100;
var num5=101;
var num6=102;
var num7=103;
var num8=104;
var num9=105;

Example how to use

$('input').keyup(function(event){
	if(event.keyCode == enter){
		//user pressed enter do code here
	}
	if(event.keyCode == escape){
		//user pressed escape do code here
	}
})

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>