[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Wait on keyboard

JT

3/11/2016 10:31:00 AM

I need to debug, and i real do not like the gist of firefox nor chrome debug.

And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?

Is there something like. wait until pressed key equal space.

Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.

So wait on keyboard?
62 Answers

Tim Streater

3/11/2016 10:37:00 AM

0

In article <6ef267d6-7655-4699-9363-d6e0f613f899@googlegroups.com>,
<jonas.thornvall@gmail.com> wrote:

>I need to debug, and i real do not like the gist of firefox nor chrome debug.
>
>And i kind of like do my own debug printouts, how can i program javascript to
>wait for keyboard input?
>
>Is there something like. wait until pressed key equal space.
>
>Is there a way to achieve this because then i will be able to do my own
>printouts to textareas and i can also see where the loop starts without to get
>indefinitly stuck or thrown out.
>
>So wait on keyboard?

That's not how it works. Javascript is event driven, so will respond
via an event handler when you press a key.

You can generate debug output visible in the debug consoles of
browsers, using statements like:

console.log ("x = " + x);

I've always found these quite useful.

--
Lady Astor: "If you were my husband I'd give you poison." Churchill: "If
you were my wife, I'd drink it."

JT

3/11/2016 10:51:00 AM

0

Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> I need to debug, and i real do not like the gist of firefox nor chrome debug.
>
> And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
>
> Is there something like. wait until pressed key equal space.
>
> Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
>
> So wait on keyboard?

To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.

If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.

Is there a reason?

JT

3/11/2016 11:13:00 AM

0

Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> >
> > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> >
> > Is there something like. wait until pressed key equal space.
> >
> > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> >
> > So wait on keyboard?
>
> To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.
>
> If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
>
> Is there a reason?

Here is the sample code someone suggested on net, and it makes you wonder.
Do they require the input to come from a specific field in a form????

Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?

Should not the keyboard listener be implicit in a programming language?
a=getkey();
if (a=="32");
document.write("You pressed return");

How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.

var waitingForEnter = false;

function appear()
{
document.getElementById("firstt").style.visibility="visible";
waitingForEnter = true;
}

function keydownHandler(e) {

if (e.keyCode == 13 && waitingForEnter) { // 13 is the enter key
document.getElementById("startrouter").style.visibility="visible";
waitingForEnter = false; // reset variable
}
}

// register your handler method for the keydown event
if (document.addEventListener) {
document.addEventListener('keydown', keydownHandler, false);
}
else if (document.attachEvent) {
document.attachEvent('onkeydown', keydownHandler);
}

JT

3/11/2016 11:24:00 AM

0

Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > >
> > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > >
> > > Is there something like. wait until pressed key equal space.
> > >
> > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > >
> > > So wait on keyboard?
> >
> > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.
> >
> > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> >
> > Is there a reason?
>
> Here is the sample code someone suggested on net, and it makes you wonder.
> Do they require the input to come from a specific field in a form????
>
> Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
>
> Should not the keyboard listener be implicit in a programming language?
> a=getkey();
> if (a=="32");
> document.write("You pressed return");
>
> How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
>
> var waitingForEnter = false;
>
> function appear()
> {
> document.getElementById("firstt").style.visibility="visible";
> waitingForEnter = true;
> }
>
> function keydownHandler(e) {
>
> if (e.keyCode == 13 && waitingForEnter) { // 13 is the enter key
> document.getElementById("startrouter").style.visibility="visible";
> waitingForEnter = false; // reset variable
> }
> }
>
> // register your handler method for the keydown event
> if (document.addEventListener) {
> document.addEventListener('keydown', keydownHandler, false);
> }
> else if (document.attachEvent) {
> document.attachEvent('onkeydown', keydownHandler);
> }

Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?

So my question why do not a simple boolean suffice to but a listener on and off?

Mouse events

onclick
oncontextmenu
ondblclick
onmousedown
onmouseenter
onmouseleave
onmousemove
onmouseover
onmouseout
onmouseup

Keyboard Events

onkeydown
onkeypress
onkeyup

JT

3/11/2016 11:32:00 AM

0

Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > >
> > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > >
> > > > Is there something like. wait until pressed key equal space.
> > > >
> > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > >
> > > > So wait on keyboard?
> > >
> > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.
> > >
> > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > >
> > > Is there a reason?
> >
> > Here is the sample code someone suggested on net, and it makes you wonder.
> > Do they require the input to come from a specific field in a form????
> >
> > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> >
> > Should not the keyboard listener be implicit in a programming language?
> > a=getkey();
> > if (a=="32");
> > document.write("You pressed return");
> >
> > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> >
> > var waitingForEnter = false;
> >
> > function appear()
> > {
> > document.getElementById("firstt").style.visibility="visible";
> > waitingForEnter = true;
> > }
> >
> > function keydownHandler(e) {
> >
> > if (e.keyCode == 13 && waitingForEnter) { // 13 is the enter key
> > document.getElementById("startrouter").style.visibility="visible";
> > waitingForEnter = false; // reset variable
> > }
> > }
> >
> > // register your handler method for the keydown event
> > if (document.addEventListener) {
> > document.addEventListener('keydown', keydownHandler, false);
> > }
> > else if (document.attachEvent) {
> > document.attachEvent('onkeydown', keydownHandler);
> > }
>
> Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
>
> So my question why do not a simple boolean suffice to but a listener on and off?
>
> Mouse events
>
> onclick
> oncontextmenu
> ondblclick
> onmousedown
> onmouseenter
> onmouseleave
> onmousemove
> onmouseover
> onmouseout
> onmouseup
>
> Keyboard Events
>
> onkeydown
> onkeypress
> onkeyup

It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".

But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?

Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?

JT

3/11/2016 11:39:00 AM

0

Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > >
> > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > >
> > > > > Is there something like. wait until pressed key equal space.
> > > > >
> > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > >
> > > > > So wait on keyboard?
> > > >
> > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.
> > > >
> > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > >
> > > > Is there a reason?
> > >
> > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > Do they require the input to come from a specific field in a form????
> > >
> > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > >
> > > Should not the keyboard listener be implicit in a programming language?
> > > a=getkey();
> > > if (a=="32");
> > > document.write("You pressed return");
> > >
> > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > >
> > > var waitingForEnter = false;
> > >
> > > function appear()
> > > {
> > > document.getElementById("firstt").style.visibility="visible";
> > > waitingForEnter = true;
> > > }
> > >
> > > function keydownHandler(e) {
> > >
> > > if (e.keyCode == 13 && waitingForEnter) { // 13 is the enter key
> > > document.getElementById("startrouter").style.visibility="visible";
> > > waitingForEnter = false; // reset variable
> > > }
> > > }
> > >
> > > // register your handler method for the keydown event
> > > if (document.addEventListener) {
> > > document.addEventListener('keydown', keydownHandler, false);
> > > }
> > > else if (document.attachEvent) {
> > > document.attachEvent('onkeydown', keydownHandler);
> > > }
> >
> > Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> >
> > So my question why do not a simple boolean suffice to but a listener on and off?
> >
> > Mouse events
> >
> > onclick
> > oncontextmenu
> > ondblclick
> > onmousedown
> > onmouseenter
> > onmouseleave
> > onmousemove
> > onmouseover
> > onmouseout
> > onmouseup
> >
> > Keyboard Events
> >
> > onkeydown
> > onkeypress
> > onkeyup
>
> It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
>
> But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
>
> Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?

And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.

Especially it you can come up with a solution using less than 10 lines of code.

Tim Streater

3/11/2016 12:14:00 PM

0

In article <41dca990-88fe-4829-8fbb-fd8811727776@googlegroups.com>,
<jonas.thornvall@gmail.com> wrote:

>Here is the sample code someone suggested on net, and it makes you wonder.
>Do they require the input to come from a specific field in a form????

How about you try thinking for yourself and researching a bit better. I
assume you're doing this within an html document so how about:

<body onkeydown="keydownHandler(event);">

and:

function keydownHandler(e)
{

if (e.keyCode==13)
{
// do stuff here when return pressed
console.log ("x = " + x);
}
else if (e.keyCode==20)
{
// Space pressed do something else
}

}


Simple enough.

--
"Once you adopt the unix paradigm, the variants cease to be a problem - you
bitch, of course, but that's because bitching is fun, unlike M$ OS's, where
bitching is required to keep your head from exploding." - S Stremler in afc

JT

3/11/2016 12:41:00 PM

0

Den fredag 11 mars 2016 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail..com:
> > > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > > >
> > > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > > >
> > > > > > Is there something like. wait until pressed key equal space.
> > > > > >
> > > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > > >
> > > > > > So wait on keyboard?
> > > > >
> > > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.
> > > > >
> > > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > > >
> > > > > Is there a reason?
> > > >
> > > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > > Do they require the input to come from a specific field in a form????
> > > >
> > > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > > >
> > > > Should not the keyboard listener be implicit in a programming language?
> > > > a=getkey();
> > > > if (a=="32");
> > > > document.write("You pressed return");
> > > >
> > > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > > >
> > > > var waitingForEnter = false;
> > > >
> > > > function appear()
> > > > {
> > > > document.getElementById("firstt").style.visibility="visible";
> > > > waitingForEnter = true;
> > > > }
> > > >
> > > > function keydownHandler(e) {
> > > >
> > > > if (e.keyCode == 13 && waitingForEnter) { // 13 is the enter key
> > > > document.getElementById("startrouter").style.visibility="visible";
> > > > waitingForEnter = false; // reset variable
> > > > }
> > > > }
> > > >
> > > > // register your handler method for the keydown event
> > > > if (document.addEventListener) {
> > > > document.addEventListener('keydown', keydownHandler, false);
> > > > }
> > > > else if (document.attachEvent) {
> > > > document.attachEvent('onkeydown', keydownHandler);
> > > > }
> > >
> > > Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> > >
> > > So my question why do not a simple boolean suffice to but a listener on and off?
> > >
> > > Mouse events
> > >
> > > onclick
> > > oncontextmenu
> > > ondblclick
> > > onmousedown
> > > onmouseenter
> > > onmouseleave
> > > onmousemove
> > > onmouseover
> > > onmouseout
> > > onmouseup
> > >
> > > Keyboard Events
> > >
> > > onkeydown
> > > onkeypress
> > > onkeyup
> >
> > It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
> >
> > But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
> >
> > Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?
>
> And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.
>
> Especially it you can come up with a solution using less than 10 lines of code.

Pseudcode.

wait until key pressed.

If you do not like wait(3000);
You could do something in the line already in language.
setKeyInput(myFunction, keyPress="32")

But i prefer wait until(keyPress=="32") anyday of the year.
And keyPress is a listener that can be turned on and off with boolean true/false.

So during execution you can chose function to be called from keyboard.
if (keyPress=="32") exit();

It so more clear than the current convolution of action. And it would enable you to steer program from keyboard. It is probably possible even now, but it is so fucking convoluted you can not see it.

I would guess that return somehow reserved for submit, but i could have use for the other 103 keyes and their combinations.

Isn't it evolution a bit fucking weird when something that required one line of code suddenly need a library?

https://dmauro.github.io...

JT

3/11/2016 1:01:00 PM

0

Den fredag 11 mars 2016 kl. 13:41:29 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail..com:
> > > > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > > > >
> > > > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > > > >
> > > > > > > Is there something like. wait until pressed key equal space.
> > > > > > >
> > > > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > > > >
> > > > > > > So wait on keyboard?
> > > > > >
> > > > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.
> > > > > >
> > > > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > > > >
> > > > > > Is there a reason?
> > > > >
> > > > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > > > Do they require the input to come from a specific field in a form????
> > > > >
> > > > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > > > >
> > > > > Should not the keyboard listener be implicit in a programming language?
> > > > > a=getkey();
> > > > > if (a=="32");
> > > > > document.write("You pressed return");
> > > > >
> > > > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > > > >
> > > > > var waitingForEnter = false;
> > > > >
> > > > > function appear()
> > > > > {
> > > > > document.getElementById("firstt").style.visibility="visible";
> > > > > waitingForEnter = true;
> > > > > }
> > > > >
> > > > > function keydownHandler(e) {
> > > > >
> > > > > if (e.keyCode == 13 && waitingForEnter) { // 13 is the enter key
> > > > > document.getElementById("startrouter").style.visibility="visible";
> > > > > waitingForEnter = false; // reset variable
> > > > > }
> > > > > }
> > > > >
> > > > > // register your handler method for the keydown event
> > > > > if (document.addEventListener) {
> > > > > document.addEventListener('keydown', keydownHandler, false);
> > > > > }
> > > > > else if (document.attachEvent) {
> > > > > document.attachEvent('onkeydown', keydownHandler);
> > > > > }
> > > >
> > > > Of course one really could ask the same for all mouse and listeners.. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> > > >
> > > > So my question why do not a simple boolean suffice to but a listener on and off?
> > > >
> > > > Mouse events
> > > >
> > > > onclick
> > > > oncontextmenu
> > > > ondblclick
> > > > onmousedown
> > > > onmouseenter
> > > > onmouseleave
> > > > onmousemove
> > > > onmouseover
> > > > onmouseout
> > > > onmouseup
> > > >
> > > > Keyboard Events
> > > >
> > > > onkeydown
> > > > onkeypress
> > > > onkeyup
> > >
> > > It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
> > >
> > > But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
> > >
> > > Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?
> >
> > And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.
> >
> > Especially it you can come up with a solution using less than 10 lines of code.
>
> Pseudcode.
>
> wait until key pressed.
>
> If you do not like wait(3000);
> You could do something in the line already in language.
> setKeyInput(myFunction, keyPress="32")
>
> But i prefer wait until(keyPress=="32") anyday of the year.
> And keyPress is a listener that can be turned on and off with boolean true/false.
>
> So during execution you can chose function to be called from keyboard.
> if (keyPress=="32") exit();
>
> It so more clear than the current convolution of action. And it would enable you to steer program from keyboard. It is probably possible even now, but it is so fucking convoluted you can not see it.
>
> I would guess that return somehow reserved for submit, but i could have use for the other 103 keyes and their combinations.
>
> Isn't it evolution a bit fucking weird when something that required one line of code suddenly need a library?
>
> https://dmauro.github.io...

Oh is see i need to learn an API so i can see what fucking key i pressed, if it wasn't a sad glimpse of a future where program language designers start to show sign of retardness it would be hilarious.

Really nobody think about programmers as users using an interface anymore?
What the fuck went wrong?

JT

3/11/2016 1:43:00 PM

0

Den fredag 11 mars 2016 kl. 14:01:05 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 13:41:29 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail..com:
> > > > > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > > > > >
> > > > > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > > > > >
> > > > > > > > Is there something like. wait until pressed key equal space.
> > > > > > > >
> > > > > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > > > > >
> > > > > > > > So wait on keyboard?
> > > > > > >
> > > > > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.
> > > > > > >
> > > > > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > > > > >
> > > > > > > Is there a reason?
> > > > > >
> > > > > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > > > > Do they require the input to come from a specific field in a form????
> > > > > >
> > > > > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > > > > >
> > > > > > Should not the keyboard listener be implicit in a programming language?
> > > > > > a=getkey();
> > > > > > if (a=="32");
> > > > > > document.write("You pressed return");
> > > > > >
> > > > > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > > > > >
> > > > > > var waitingForEnter = false;
> > > > > >
> > > > > > function appear()
> > > > > > {
> > > > > > document.getElementById("firstt").style.visibility="visible";
> > > > > > waitingForEnter = true;
> > > > > > }
> > > > > >
> > > > > > function keydownHandler(e) {
> > > > > >
> > > > > > if (e.keyCode == 13 && waitingForEnter) { // 13 is the enter key
> > > > > > document.getElementById("startrouter").style.visibility="visible";
> > > > > > waitingForEnter = false; // reset variable
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > // register your handler method for the keydown event
> > > > > > if (document.addEventListener) {
> > > > > > document.addEventListener('keydown', keydownHandler, false);
> > > > > > }
> > > > > > else if (document.attachEvent) {
> > > > > > document.attachEvent('onkeydown', keydownHandler);
> > > > > > }
> > > > >
> > > > > Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> > > > >
> > > > > So my question why do not a simple boolean suffice to but a listener on and off?
> > > > >
> > > > > Mouse events
> > > > >
> > > > > onclick
> > > > > oncontextmenu
> > > > > ondblclick
> > > > > onmousedown
> > > > > onmouseenter
> > > > > onmouseleave
> > > > > onmousemove
> > > > > onmouseover
> > > > > onmouseout
> > > > > onmouseup
> > > > >
> > > > > Keyboard Events
> > > > >
> > > > > onkeydown
> > > > > onkeypress
> > > > > onkeyup
> > > >
> > > > It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
> > > >
> > > > But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
> > > >
> > > > Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?
> > >
> > > And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.
> > >
> > > Especially it you can come up with a solution using less than 10 lines of code.
> >
> > Pseudcode.
> >
> > wait until key pressed.
> >
> > If you do not like wait(3000);
> > You could do something in the line already in language.
> > setKeyInput(myFunction, keyPress="32")
> >
> > But i prefer wait until(keyPress=="32") anyday of the year.
> > And keyPress is a listener that can be turned on and off with boolean true/false.
> >
> > So during execution you can chose function to be called from keyboard.
> > if (keyPress=="32") exit();
> >
> > It so more clear than the current convolution of action. And it would enable you to steer program from keyboard. It is probably possible even now, but it is so fucking convoluted you can not see it.
> >
> > I would guess that return somehow reserved for submit, but i could have use for the other 103 keyes and their combinations.
> >
> > Isn't it evolution a bit fucking weird when something that required one line of code suddenly need a library?
> >
> > https://dmauro.github.io...
>
> Oh is see i need to learn an API so i can see what fucking key i pressed, if it wasn't a sad glimpse of a future where program language designers start to show sign of retardness it would be hilarious.
>
> Really nobody think about programmers as users using an interface anymore?
> What the fuck went wrong?

What i try to say, i think there may be an anal beadhead responsible for implementing the javascript liteners. It is not that i do not recognize the requirment to listen to interactive elements by id. It is the way it is implemented that is retarded and then i am prety kind to the one who implemented it.