File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed
Expand file tree Collapse file tree 3 files changed +107
-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+ < title > Check Keyboard</ title >
6+
7+ <!-- css -->
8+ < link rel ="stylesheet " href ="style.css ">
9+
10+ </ head >
11+
12+ < body id ="canvas ">
13+ < div >
14+ < div id ="userinput "> </ div >
15+ < h1 > press a key</ h1 >
16+ </ div >
17+
18+ < div class ="keyData ">
19+ </ div >
20+ </ body >
21+
22+ <!-- js -->
23+ < script src ="script.js "> </ script >
24+ </ html >
Original file line number Diff line number Diff line change 1+ const userinput = document . querySelector ( '#userinput' ) ;
2+
3+ const keyData = document . querySelector ( '.keyData' ) ;
4+
5+ // key detector
6+ window . addEventListener ( 'keydown' , ( e ) => {
7+ userinput . innerHTML = `${ e . key === ' ' ? 'Space' : e . key } ` ;
8+
9+ keyData . innerHTML = `
10+ <table border="">
11+ <tr>
12+ <th>Key</th>
13+ <th>KeyCode</th>
14+ <th>Code</th>
15+ </tr>
16+ <tr>
17+ <td>${ e . key === ' ' ? 'Space' : e . key } </td>
18+ <td>${ e . keyCode } </td>
19+ <td>${ e . code } </td>
20+ </tr>
21+ </table>
22+ ` ;
23+
24+ } ) ;
25+
26+
27+ // screen cleaner
28+ let clear = function ( ) {
29+ userinput . innerHTML = '' ;
30+ keyData . innerHTML = '' ;
31+ } ;
32+
33+ setInterval ( clear , 5000 )
Original file line number Diff line number Diff line change 1+ * {
2+ margin : 0 ;
3+ padding : 0 ;
4+ box-sizing : border-box;
5+ }
6+
7+ body {
8+ background-color : bisque;
9+ font-family : monospace;
10+ }
11+
12+ # canvas {
13+ display : flex;
14+ justify-content : center;
15+ align-items : center;
16+ flex-direction : column;
17+ height : 90vh ;
18+ text-align : center;
19+ }
20+
21+ # userinput {
22+ font-size : 3em ;
23+ border-bottom : 2px solid black;
24+ margin : 15px ;
25+ height : 60px ;
26+ }
27+
28+ .keyData {
29+ margin : 1rem ;
30+ font-size : large;
31+ }
32+
33+ @media (max-width : 500px ) {
34+ # canvas {
35+ display : flex;
36+ justify-content : center;
37+ align-items : center;
38+ flex-direction : column;
39+ font-size : 0.9em ;
40+ height : 60vh ;
41+ text-align : center;
42+ }
43+
44+ # userinput {
45+ font-size : 3em ;
46+ border-bottom : 2px solid black;
47+ margin : 0.5rem ;
48+ height : 50px ;
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments