Does anyone know how I can know what the user is typing? I tried to make it like this 😅 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Does anyone know how I can know what the user is typing? I tried to make it like this 😅

https://code.sololearn.com/WSRJu16cVU05/?ref=app

24th Feb 2023, 3:32 PM
Pooja Sahoo
Pooja Sahoo - avatar
7 Answers
+ 6
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <input type="text"> <p></p> <script> document.querySelector("input").addEventListener("input",()=>{ document.querySelector("p").innerHTML=document.querySelector("input").value; }); </script> </body> </html>
24th Feb 2023, 11:51 PM
Dev Nasfam
Dev Nasfam - avatar
+ 4
💗💗
25th Feb 2023, 4:47 AM
Dev Nasfam
Dev Nasfam - avatar
+ 3
with that e.key you get only the key. If you want to read the text entered in the input element, add event "change" or "input" to that input element and read the entire value. keydown to that input works too.
24th Feb 2023, 3:45 PM
Arturop
Arturop - avatar
+ 2
Try the above-mentioned
24th Feb 2023, 11:52 PM
Dev Nasfam
Dev Nasfam - avatar
+ 2
Thanks to all 🤗
25th Feb 2023, 2:49 AM
Pooja Sahoo
Pooja Sahoo - avatar
+ 1
cool! i like what you did that seems perfect.
22nd Mar 2023, 4:26 PM
𝕃𝕚𝕥𝕥𝕝𝕖𝕆𝕥𝕥𝕖𝕣
𝕃𝕚𝕥𝕥𝕝𝕖𝕆𝕥𝕥𝕖𝕣 - avatar
0
Cool
26th Feb 2023, 1:59 PM
EFRAIM BANGUN
EFRAIM BANGUN - avatar