File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* CSS RESET */
2+ * {
3+ margin : 0px ;
4+ padding : 0px ;
5+ }
6+
7+ .con {
8+ height : 100vh ;
9+ /* border: 2px solid black; */
10+ display : flex;
11+ justify-content : center;
12+ align-items : center;
13+ }
14+
15+ .con ::before {
16+ content : "" ;
17+ position : absolute;
18+ background : url (mic.jpg);
19+ background-position : center center;
20+ height : 100% ;
21+ width : 100% ;
22+ z-index : -1 ;
23+ opacity : 0.8 ;
24+ }
25+ .pause {
26+
27+ font-size : 20px ;
28+ border : 2px solid rgb (199 252 7 / 36% );
29+ position : absolute;
30+ top : 200px ;
31+ right : 682px ;
32+ font-family : 'Times New Roman' , Times, serif;
33+ background-color : # 332c33e6 ;
34+ }
35+ .pause span {
36+ color : white;
37+ }
38+
39+
40+
41+ .key {
42+ cursor : pointer;
43+ color : white;
44+ font-weight : bolder;
45+ border : 2px solid gray;
46+ font-size : 1.7em ;
47+ padding : 10px 10px ;
48+ background-color : # 332c334d ;
49+ margin : 10px 40px ;
50+ transition : all 0.5s ;
51+ }
52+ kbd {
53+ text-align : center;
54+ display : block;
55+ font-size : 0.8em ;
56+ }
57+
58+ .playing {
59+ transform : scale (1.3 );
60+ border : 3px solid rgb (199 , 252 , 7 );
61+
62+ }
Original file line number Diff line number Diff line change 1+
2+ window . addEventListener ( 'keydown' , function ( e ) {
3+ let audio = document . querySelector ( `audio[data-key = "${ e . keyCode } "]` ) ;
4+
5+ if ( audio == null ) return ; // Stops the function from running if we press any ir-releveant key
6+ audio . currentTime = 0 ; // To rewind the song if we press the key Again
7+ audio . play ( ) ;
8+ console . log ( 'we are at 1' ) ;
9+
10+ // Now Adding class Playing
11+
12+ let grab = document . querySelector ( `.key[data-key = "${ e . keyCode } "]` ) ;
13+ grab . classList . add ( 'playing' ) ; // Adding Class Playing
14+
15+
16+ // PAUSE
17+ // ---------------
18+
19+ window . addEventListener ( 'keydown' , function ( e ) {
20+ let pause = e . keyCode ;
21+ if ( pause == 80 ) {
22+ audio . pause ( ) ;
23+ grab . classList . remove ( 'playing' ) ;
24+ }
25+ } ) ;
26+ // ----------------
27+
28+ // Click to Play
29+
30+
31+
32+ // Removing transition when audio ends
33+
34+ function removeTransition ( e ) {
35+ if ( e . propertyName !== 'transform' ) return ;
36+ this . classList . remove ( 'playing' ) ;
37+ }
38+
39+
40+ } ) ;
You can’t perform that action at this time.
0 commit comments