Author Topic: Key Bounces  (Read 198 times)

Offline Mikey

  • Jr. Member
  • **
  • Posts: 63
Key Bounces
« on: December 02, 2018, 03:58:39 AM »
*** Delete This thread. I found the answer ***

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 1350
  • You secure that shit Hudson!!
Re: Key Bounces
« Reply #1 on: December 02, 2018, 01:53:24 PM »
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
Windows 10, 64-bit, 8Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)

Offline Mikey

  • Jr. Member
  • **
  • Posts: 63
Key Bounces
« Reply #2 on: December 02, 2018, 10:06:38 PM »
NO,

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

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 1350
  • You secure that shit Hudson!!
Re: Key Bounces
« Reply #3 on: December 02, 2018, 10:42:45 PM »
Anything that could possible help the community could never be called a waste of server space.   :)
Windows 10, 64-bit, 8Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)

Offline Mikey

  • Jr. Member
  • **
  • Posts: 63
Key Bounces
« Reply #4 on: December 02, 2018, 11:14:09 PM »
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.

Code: [Select]
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

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1321
Re: Key Bounces
« Reply #5 on: December 02, 2018, 11:54:47 PM »
Quote
I 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 :)
Until the next time...

Offline Mikey

  • Jr. Member
  • **
  • Posts: 63
Key Bounces
« Reply #6 on: December 03, 2018, 12:11:30 AM »
Yes, but at some point the cost has to be ridiculous and then where would the information go?

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1321
Re: Key Bounces
« Reply #7 on: December 03, 2018, 12:12:20 AM »
Yes, but at some point the cost has to be ridiculous and then where would the information go?
An even bigger drive :P
Until the next time...

Offline Mikey

  • Jr. Member
  • **
  • Posts: 63
Key Bounces
« Reply #8 on: December 03, 2018, 01:42:32 AM »
It will bankrupt you in the very long run.

Offline Derron

  • Hero Member
  • *****
  • Posts: 1521
Re: Key Bounces
« Reply #9 on: December 03, 2018, 07:08:29 AM »
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

Offline Mikey

  • Jr. Member
  • **
  • Posts: 63
Key Bounces
« Reply #10 on: December 03, 2018, 10:05:40 PM »
This was the solution that I used:

Code: [Select]
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