File tree 2 files changed +25
-2
lines changed
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change
1
+ // keypress - when key is pressed
2
+ // keydown - when key is down
3
+ // keyup - when key is released
4
+
5
+ const inputName = document . querySelector ( '.inputName' ) ;
6
+
7
+ inputName . addEventListener ( 'keypress' , function ( ) {
8
+ console . dir ( 'u r press key' ) ;
9
+ } ) ;
10
+
11
+ // inputName.addEventListener('keydown', function () {
12
+ // console.log('u r press key');
13
+ // });
14
+
15
+ // inputName.addEventListener('keyup', function () {
16
+ // console.dir(inputName);
17
+ // });
Original file line number Diff line number Diff line change @@ -141,10 +141,15 @@ <h2>On container</h2>
141
141
<h1>Hello World</h1>
142
142
</div> -->
143
143
144
+ <!-- addEventListener, function reference
144
145
<div class="container">
145
146
<h3>The Pirates</h3>
146
147
<button class="btn">Join</button>
147
- </ div >
148
+ </div> -->
149
+
150
+ <!-- key events -->
151
+ < input type ="text " class ="inputName " />
152
+
148
153
<!-- source js -->
149
154
<!-- <script src="/01_getElementById.js"></script> -->
150
155
<!-- <script src="/02_getElementByTagName.js"></script> -->
@@ -163,6 +168,7 @@ <h3>The Pirates</h3>
163
168
<!-- <script src="/15_remove_removeChild.js"></script> -->
164
169
<!-- <script src="/16_innerHTML_textContent.js"></script> -->
165
170
<!-- <script src="/17.addEventListener.js"></script> -->
166
- < script src ="/18_function_reference.js "> </ script >
171
+ <!-- <script src="/18_function_reference.js"></script> -->
172
+ < script src ="/19_key_events.js "> </ script >
167
173
</ body >
168
174
</ html >
You can’t perform that action at this time.
0 commit comments