Key Bounces

Started by Mikey, December 02, 2018, 03:58:39

Previous topic - Next topic

Mikey

*** Delete This thread. I found the answer ***

Steve Elliott

So you had a problem that others might also have, and you've found the solution.  Now you want to keep the solution to yourself?   :P
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Mikey

NO,

I did not want to take up server space. I can post the source again if you want.

Steve Elliott

Anything that could possible help the community could never be called a waste of server space.   :)
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Mikey

I understand.
Some sites do complain.

Here is the original source. The problem is that the machine is so fast that it does not increment one at a time. It goes from the first to the last, instantly.


While Not KeyDown(1)
If KeyDown(208) And STLI<(NF-(ENDL-1))
STLI=STLI+1:Cls:Gosub PL:;ENDL=ENDL+1:
ElseIf KeyDown(200) And STLI>1
STLI=STLI-1:Cls:Gosub PL:;ENDL=ENDL-1
EndIf
For Z=1 To 10:Text 200,13*(Z-1),T$(Z):Next:;WaitKey:End

Text 150,0,STLI;VWait

Wend
End

Qube

QuoteI did not want to take up server space.... Some sites do complain.
Don't worry about that. If the SSD gets full I'll just buy a bigger SSD ;D - Keep posting :)
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Mikey

Yes, but at some point the cost has to be ridiculous and then where would the information go?

Qube

Quote from: Mikey on December 03, 2018, 00:11:30
Yes, but at some point the cost has to be ridiculous and then where would the information go?
An even bigger drive :P
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Mikey

It will bankrupt you in the very long run.

Derron

Every byte counts !!!11!!!!!1

Once Mikey posted his 1.000.000.000 post he will occupy ~ 1kb * 1.000.000.000 = ~100 gigabytes on your SSD. Assume he does not "bot-post" but manual post and needs about a minute to write some stuff then he will have filled your SSD/hard drive in just about 695.000 days. I assume when this moment comes, 100 gigabytes of space won't cost uhm "that much" ;-)


@ keydown
The problem is that "keydown" is emitted as soon as a key is "kept down" and the code handling the OS events is run. So on your fast computer it runs runs runs runs runs ... and always it sees "key is down -> keydown becomes true".

Solution is to have some kind of "keyHit" (becomes "true" once it _was_ keydown but now is _no_longer_ keydown). Or you add your own "KeyPress()". Means you store when KeyDown/KeyHit/... events for a special key happen. Then add your own timing code (eg. you can only "keyPress" once every X milliseconds). This also allows for "repeat key strokes"). You while the user keeps pressing a key ("keyDown=true everytime") you store a "keyDownTime = Millisecs()" thing as soon as "keyDownTime - lastKeyDownTime > xxx". If you update "lastKeyDownTime" then to the current time it will emit it next time once "xxx" time has passed. This allows then to keep it pressed but only emit a "keystroke" every xxx time.


bye
Ron

Mikey

This was the solution that I used:

While Not KeyDown(1)
CH=GetKey()
If CH<>0
If KeyDown(208) And STLI<(NF-(ENDL-1))
STLI=STLI+1:Cls:Gosub PL:;ENDL=ENDL+1:
ElseIf KeyDown(200) And STLI>1
STLI=STLI-1:Cls:Gosub PL:;ENDL=ENDL-1
EndIf
For Z=1 To 10:Text 200,13*(Z-1),T$(Z):Next:;WaitKey:End

EndIf
Wend


It does not emit a repeating key press if the key is held down though