File tree 4 files changed +87
-6
lines changed
4 files changed +87
-6
lines changed Original file line number Diff line number Diff line change 3
3
< head >
4
4
< meta charset ="UTF-8 " />
5
5
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6
- <!-- <link
7
- rel="stylesheet"
8
- href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
9
- integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
10
- crossorigin="anonymous"
11
- /> -->
12
6
< link rel ="stylesheet " href ="style.css " />
13
7
< title > Dad Jokes</ title >
14
8
</ head >
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
7
+ rel="stylesheet"
8
+ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
9
+ integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
10
+ crossorigin="anonymous"
11
+ /> -->
12
+ < link rel ="stylesheet " href ="style.css " />
13
+ < title > Event KeyCodes</ title >
14
+ </ head >
15
+ < body >
16
+ < div id ="insert ">
17
+ < div class ="key "> Press any key to get the keyCode</ div >
18
+ </ div >
19
+ < script src ="script.js "> </ script >
20
+ </ body >
21
+ </ html >
Original file line number Diff line number Diff line change
1
+ const insert = document . getElementById ( "insert" ) ;
2
+
3
+ window . addEventListener ( "keydown" , ( event ) => {
4
+ insert . innerHTML = `
5
+ <div class="key">
6
+ ${ event . key === " " ? "Space" : event . key }
7
+ <small>event.key</small>
8
+ </div>
9
+ <div class="key red">
10
+ ${ event . keyCode }
11
+ <small>event.keyCode (old)</small>
12
+ </div>
13
+ <div class="key green">
14
+ ${ event . code }
15
+ <small>event.code (new)</small>
16
+ </div>` ;
17
+ } ) ;
Original file line number Diff line number Diff line change
1
+ @import url ("https://fonts.googleapis.com/css2?family=Muli&display=swap" );
2
+
3
+ * {
4
+ box-sizing : border-box;
5
+ }
6
+
7
+ body {
8
+ background-color : # e1e1e1 ;
9
+ font-family : "Muli" , sans-serif;
10
+ display : flex;
11
+ align-items : center;
12
+ justify-content : center;
13
+ text-align : center;
14
+ height : 100vh ;
15
+ overflow : hidden;
16
+ margin : 0 ;
17
+ }
18
+
19
+ .key {
20
+ background-color : # eee ;
21
+ box-shadow : 1px 1px 3px rgba (0 , 0 , 0 , 0.1 );
22
+ display : inline-flex;
23
+ align-items : center;
24
+ font-size : 20px ;
25
+ font-weight : bold;
26
+ padding : 20px ;
27
+ flex-direction : column;
28
+ margin : 10px ;
29
+ min-width : 150px ;
30
+ position : relative;
31
+ }
32
+
33
+ .key small {
34
+ position : absolute;
35
+ top : -24px ;
36
+ left : 0 ;
37
+ text-align : center;
38
+ width : 100% ;
39
+ color : # 555 ;
40
+ font-size : 14px ;
41
+ }
42
+
43
+ .red {
44
+ color : # ab5052 ;
45
+ }
46
+
47
+ .green {
48
+ color : # 60986f ;
49
+ }
You can’t perform that action at this time.
0 commit comments