File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
JavaScript Project/keypress Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < link rel ="stylesheet " href ="style.css " />
7+ < title > Event KeyCodes</ title >
8+ < link rel ="stylesheet " type ="text/css " href ="../styles.css " />
9+ < style >
10+ table ,
11+ th ,
12+ td {
13+ border : 1px solid # e7e7e7 ;
14+ }
15+ .project {
16+ background-color : # 1c1c1c ;
17+ color : # ffffff ;
18+ display : flex;
19+ align-items : center;
20+ justify-content : center;
21+ text-align : center;
22+ height : 100vh ;
23+ }
24+
25+ .color {
26+ color : aliceblue;
27+ display : flex;
28+ flex-direction : row;
29+ }
30+ </ style >
31+ </ head >
32+ < body >
33+
34+ < div class ="project ">
35+ < div id ="insert ">
36+ < div class ="key "> Press the key and watch magic</ div >
37+ </ div >
38+ </ div >
39+
40+ < script src ="./script.js "> </ script >
41+ </ body >
42+ </ html >
Original file line number Diff line number Diff line change 1+ const insert = document . getElementById ( 'insert' ) ;
2+
3+ window . addEventListener ( 'keydown' , ( e ) => {
4+ insert . innerHTML = `
5+ <div class='color'>
6+ <table>
7+ <tr>
8+ <th>Key</th>
9+ <th>Keycode</th>
10+ <th>Code</th>
11+ </tr>
12+ <tr>
13+ <td>${ e . key === ' ' ? 'Space' : e . key } </td>
14+ <td>${ e . keyCode } </td>
15+ <td>${ e . code } </td>
16+ </tr>
17+
18+ </table>
19+ </div>
20+ ` ;
21+ } ) ;
You can’t perform that action at this time.
0 commit comments