Control keyboard button using javascript ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Control keyboard button using javascript ?

HOW TO CONTROL PC KEYBOARD WITH JAVASCRIPT IN WEB BROWSER FOR EXAMPLE I WANT TO PRESS THE ENTER KEY TWICE WHEN I WANT SO HOW DOES IT POSSIBLE AND HOW IT HAPPEND ITS GONE MAJOR PROBLEM FOR ME PLEASE HELP ME ANY DEVELOPER PROVIDE ME CODE TO PRESS AUTOMATICALLY KEYBOARD KEY'S

26th Aug 2018, 2:53 PM
Jitender Kashyap
Jitender Kashyap - avatar
12 Answers
- 3
I have posted my answear, what's wrong with this? I have tell you that it is not possible with javascript!!! I recomend you to stop programming, not all humans are made for this
26th Aug 2018, 7:39 PM
BraveHornet
BraveHornet - avatar
+ 4
Here you go: var enterCnt = 0; window.onload = function() { document.addEventListener("keydown", function(event) { var key = event.which || event.keyCode; if(key==13) { if(enterCnt<1) { enterCnt++; } else { console.log("Double enter key detected"); enterCnt = 0; } } else enterCnt = 0; }); } https://code.sololearn.com/WCMRyqTKb4U0/?ref=app PS: Jitender Kashyap Please do not write your question in all capital letters, it cannot draw any attention, only made it hard to read.
26th Aug 2018, 3:25 PM
Calviղ
Calviղ - avatar
0
Really, you can't hacking with Javascript. If you want to make a keylogger or something like that, forget it. Javascript isn't made for spying the clients, so you can't get acces to the keyboard of an user. For that, you need an other language. C or C++ is often used for that, but Im really unsure, so correct me if im wrong. But maybe I interpret your question wrong and you mean something different, then try to ask different.
26th Aug 2018, 3:10 PM
BraveHornet
BraveHornet - avatar
0
i dont want to detect i want to pressed the keyboard key code without touch the keyboard pc help me this out
26th Aug 2018, 3:58 PM
Jitender Kashyap
Jitender Kashyap - avatar
0
i ctrl u minecraft what a bullshit why can not all possibilites will be reversed its possible i will make it possible and also learn any body have programmer not in language but all in his life what should he do to take a action before him.
27th Aug 2018, 3:12 AM
Jitender Kashyap
Jitender Kashyap - avatar
0
Do what you want, but it would be better to learn english at first, I really don't know what you want to tell us. You did't understand what the concept of programming languges is. And no, it's not possible, you are just a bit stupid right?
27th Aug 2018, 4:24 AM
BraveHornet
BraveHornet - avatar
0
go to hell
27th Aug 2018, 5:36 AM
Jitender Kashyap
Jitender Kashyap - avatar
0
don't make sololearn to a social app
27th Aug 2018, 5:37 AM
Jitender Kashyap
Jitender Kashyap - avatar
0
Jitender Kashyap Js (in browser context) run in a sanbox environment where client is protected from various unhappy scenarious. You have not much control on system (and keyboard is part of) but only on site that belong your script for security reasons.... Next try to describe an example of your case Minecraft Destroyer HD Stop offense other users... A mod yet say you this and if you dont understand, you have to think who really is stupid
27th Aug 2018, 8:05 AM
KrOW
KrOW - avatar
0
KrOW I explained it very understandably to mr india, that it's not possible and he has not even read it and ask the same question again. It's very hard not to comment that. So I recommend him to stop programming, because he isn't able to learn programming. Programming isn't for everyone. But ok, next time I will write nothing.
27th Aug 2018, 9:21 AM
BraveHornet
BraveHornet - avatar
0
Minecraft Destroyer HD Your answers are ok while they dont contain offensive words/phrases... This is the problem... Sometimes its hard not reply but seem that for you its very natural be offensive and canjot understand that exist reply without offend other user
27th Aug 2018, 10:32 AM
KrOW
KrOW - avatar
0
ok be a friend dont mind
27th Aug 2018, 11:27 AM
Jitender Kashyap
Jitender Kashyap - avatar