Sometimes we need to trigger an action when a particular key is pressed. For this we need to know which key is pressed . We can easily know this by following jQuery Code:

keyboard keycodes

If we have a input field with class .code. Then we will check which key is pressed on jQuery’s keyup event.

Input a character

You have pressed NA. Its Key Code is NA
Key Code
a 65
b 66
c 67
d 68
e 69
f 70
g 71
h 72
i 73
j 74
k 75
l 76
m 77
n 78
o 79
p 80
q 81
r 82
s 83
t 84
u 85
v 86
w 87
x 88
y 89
z 90
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
0 48
Tab 9
CapsLock 20
Shift 16
Ctrl 17
Window Key 91
Alt 18
Space 32
Esc 27
Backspace 8
Enter 13
173
= 61
[ 219
] 221
\ 220
; 59
222
, 188
. 190
/ 191
Arrow Left 37
Arrow Up 38
Arrow Right 39
Arrow Down 40
Home 36
Page Up 33
Page Down 34
End 35
F1 112
F2 113
F3 114
F4 115
F5 116
F6 117
F7 118
F9 120
F10 121
F11 122
F12 123
Scroll 145
pause 19
insert 45
delete 46
Know keyboard keycodes UG ArticlesjQueryProgrammingUncategorized,,
// Sometimes we need to trigger an action when a particular key is pressed. For this we need to know which key is pressed . We can easily know this by following jQuery Code: If we have a input field with class .code. Then we will check which key is...
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script><script>// <![CDATA[ $(document).ready(function(){ $('.code').keyup(function(e){ var code = e.keyCode ||e.which; $('.whatPressed span').text(''); $('.whatPressed span').text($("#"+code).text()); $('.whatPressed .codenumber').text(''); $('.whatPressed .codenumber').text(code); }); }); // ]]></script> Sometimes we need to trigger an action when a particular key is pressed. For this we need to know which key is pressed . We can easily know this by following jQuery Code: <a href="http://www.grasphub.com/wp-content/uploads/2014/04/top_view.jpg"><img class="aligncenter size-full wp-image-2776" src="http://www.grasphub.com/wp-content/uploads/2014/04/top_view.jpg" alt="keyboard keycodes" width="542" height="292" /></a> If we have a input field with class <strong>.code</strong>. Then we will check which key is pressed on jQuery's <strong>keyup</strong> event. Input a character <input class="code" type="text" /> <div class="whatPressed">You have pressed <b><span>NA</span></b>. Its Key Code is <b><span class="codenumber">NA</span></b></div> <div class="whatPressed"></div> <table style="height: 1998px;" width="146"> <tbody> <tr> <th>Key</th> <th>Code</th> </tr> <tr> <td id="65">a</td> <td>65</td> </tr> <tr> <td id="66">b</td> <td>66</td> </tr> <tr> <td id="67">c</td> <td>67</td> </tr> <tr> <td id="68">d</td> <td>68</td> </tr> <tr> <td id="69">e</td> <td>69</td> </tr> <tr> <td id="70">f</td> <td>70</td> </tr> <tr> <td id="71">g</td> <td>71</td> </tr> <tr> <td id="72">h</td> <td>72</td> </tr> <tr> <td id="73">i</td> <td>73</td> </tr> <tr> <td id="74">j</td> <td>74</td> </tr> <tr> <td id="75">k</td> <td>75</td> </tr> <tr> <td id="76">l</td> <td>76</td> </tr> <tr> <td id="77">m</td> <td>77</td> </tr> <tr> <td id="78">n</td> <td>78</td> </tr> <tr> <td id="79">o</td> <td>79</td> </tr> <tr> <td id="80">p</td> <td>80</td> </tr> <tr> <td id="81">q</td> <td>81</td> </tr> <tr> <td id="82">r</td> <td>82</td> </tr> <tr> <td id="83">s</td> <td>83</td> </tr> <tr> <td id="84">t</td> <td>84</td> </tr> <tr> <td id="85">u</td> <td>85</td> </tr> <tr> <td id="86">v</td> <td>86</td> </tr> <tr> <td id="87">w</td> <td>87</td> </tr> <tr> <td id="88">x</td> <td>88</td> </tr> <tr> <td id="89">y</td> <td>89</td> </tr> <tr> <td id="90">z</td> <td>90</td> </tr> <tr> <td id="49">1</td> <td>49</td> </tr> <tr> <td id="50">2</td> <td>50</td> </tr> <tr> <td id="51">3</td> <td>51</td> </tr> <tr> <td id="52">4</td> <td>52</td> </tr> <tr> <td id="53">5</td> <td>53</td> </tr> <tr> <td id="54">6</td> <td>54</td> </tr> <tr> <td id="55">7</td> <td>55</td> </tr> <tr> <td id="56">8</td> <td>56</td> </tr> <tr> <td id="57">9</td> <td>57</td> </tr> <tr> <td id="48">0</td> <td>48</td> </tr> <tr> <td id="9">Tab</td> <td>9</td> </tr> <tr> <td id="20">CapsLock</td> <td>20</td> </tr> <tr> <td id="16">Shift</td> <td>16</td> </tr> <tr> <td id="17">Ctrl</td> <td>17</td> </tr> <tr> <td id="91">Window Key</td> <td>91</td> </tr> <tr> <td id="18">Alt</td> <td>18</td> </tr> <tr> <td id="32">Space</td> <td>32</td> </tr> <tr> <td id="27">Esc</td> <td>27</td> </tr> <tr> <td id="8">Backspace</td> <td>8</td> </tr> <tr> <td id="13">Enter</td> <td>13</td> </tr> <tr> <td id="173">-</td> <td>173</td> </tr> <tr> <td id="61">=</td> <td>61</td> </tr> <tr> <td id="219">[</td> <td>219</td> </tr> <tr> <td id="221">]</td> <td>221</td> </tr> <tr> <td id="220">\</td> <td>220</td> </tr> <tr> <td id="59">;</td> <td>59</td> </tr> <tr> <td id="222">'</td> <td>222</td> </tr> <tr> <td id="188">,</td> <td>188</td> </tr> <tr> <td id="190">.</td> <td>190</td> </tr> <tr> <td id="191">/</td> <td>191</td> </tr> <tr> <td id="37">Arrow Left</td> <td>37</td> </tr> <tr> <td id="38">Arrow Up</td> <td>38</td> </tr> <tr> <td id="39">Arrow Right</td> <td>39</td> </tr> <tr> <td id="40">Arrow Down</td> <td>40</td> </tr> <tr> <td id="36">Home</td> <td>36</td> </tr> <tr> <td id="33">Page Up</td> <td>33</td> </tr> <tr> <td id="34">Page Down</td> <td>34</td> </tr> <tr> <td id="35">End</td> <td>35</td> </tr> <tr> <td id="112">F1</td> <td>112</td> </tr> <tr> <td id="113">F2</td> <td>113</td> </tr> <tr> <td id="114">F3</td> <td>114</td> </tr> <tr> <td id="115">F4</td> <td>115</td> </tr> <tr> <td id="116">F5</td> <td>116</td> </tr> <tr> <td id="117">F6</td> <td>117</td> </tr> <tr> <td id="118">F7</td> <td>118</td> </tr> <tr> <td id="120">F9</td> <td>120</td> </tr> <tr> <td id="121">F10</td> <td>121</td> </tr> <tr> <td id="122">F11</td> <td>122</td> </tr> <tr> <td id="123">F12</td> <td>123</td> </tr> <tr> <td id="145">Scroll</td> <td>145</td> </tr> <tr> <td id="19">pause</td> <td>19</td> </tr> <tr> <td id="45">insert</td> <td>45</td> </tr> <tr> <td id="46">delete</td> <td>46</td> </tr> </tbody> </table>