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.