Author Topic: Using INKEY$ and on screen movement  (Read 2618 times)

0 Members and 1 Guest are viewing this topic.

Offline Jaze

  • Newbie
  • Posts: 86
    • View Profile
Using INKEY$ and on screen movement
« on: May 19, 2021, 12:54:45 am »
I'm using INKEY$ to read the left and right arrow keys. The trouble I'm having is when the arrow key is held down. When the arrow key is pressed, the paddle on the screen moves in the corresponding direction. When the arrow key is held down the paddle moves once, pauses for a moment and then moves continuously. Is there any way to get rid of that pause?

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Using INKEY$ and on screen movement
« Reply #1 on: May 19, 2021, 01:28:38 am »
I think the delay is controlled by the OS. 

Marked as best answer by Jaze on May 19, 2021, 12:27:10 am

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Using INKEY$ and on screen movement
« Reply #2 on: May 19, 2021, 03:16:12 am »
Hi the delay is the Os wait time before auto repeat starts best way to avoid it is to use _keydown instead.
Brian ...

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Using INKEY$ and on screen movement
« Reply #3 on: May 19, 2021, 10:24:09 am »
In the old QBasic days, we used INP for that, which is still available in QB64. INP has some baggage of its own, as to how to implement it properly. The new key functions, like the example given in a previous text, would probably be your best bet. QB64 aslso offers _KEYCLEAR, if you need to clear the keyboard buffer.

INKEY$ is great for text programs, but was not made gaming.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/