Qbasicnews.com

Full Version: Changing Repeat Rate of Keystrokes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
In my RPG, the overworld seems to be a whole lot better if the keystroke repeat rate is way up.... because to move 2 pixels any direction you push the arrow keys... thus if you hold down the arrow key you will go faster. However, if the repeat rate is low then the guy wont move as fast. So the question is:

Is there a way to change the repeat rate of the user's input in QB (and then change it back to their settings when they go back to windows or whatever)?

The keystroke repeat rate can be found in the Control Panel under Keyboard (makes sense.) There are probably alternatives to doing this... so if you know any alternatives (besides making each keystroke move the guy 4 pixels instead of 2) that would also be helpful.

Thanks.
there is a DOS command to change the keyrate. I forget what it is, but you can SHELL and do it.

If I find it before the next poster, I'll letcha know Smile

*peace*

Meg.
there is a DOS command to change the keyrate. I forget what it is, but you can SHELL and do it.

Here, found it.

Code:
SHELL "mode con rate=23 delay=1"

you can play with the numbers to your liking.

*peace*

Meg.
You can use a keyboard handler or just read port &H60 instead of using INKEY$.

Please DON'T USE INKEY$!!! Big Grin
Here's a way that works for me.

Whoah....i just trieddd itt with aaa zeroo value .... fasstt....

- Davvvv

Code:
'   From Ethan Winer's book "BASIC: Techniques and Utilities" (available
'   in freeware form in the WINER.ZIP file):

'   Keyboard Ports

'   There are several ports associated with the keyboard, and one is of
'   particular interest. The enhanced keyboards that come with AT-class
'   and later computers allow you to control how quickly keystrokes are
'   repeated automatically. There are actually two values - one sets the
'   initial delay before keys begin to repeat, and the other establishes
'   the repeat rate. By sending the correct values through the keyboard
'   port, you can control the keyboard's typematic response. The complete
'   program that follows shows how to do this, and Table 10.3 shows how
'   the delay and repeat values are determined.

   OUT &H60, &HF3        ' get keyboard's attention
   FOR D& = 1 TO 100     ' brief delay to give the hardware time to settle
   NEXT

   Value = 7             ' 1/4 second initial delay, 16 CPS
   OUT &H60, Value

'   Table 10.3 shows only some of the possible values that can be used.
'   However, you can interpolate additional values for delay times and
'   repeat rates between those shown.

'  Table 10.3
'  Sample Values for Setting the initial and Repeat Rate on AT-Style Keyboard
'  --------------------------------------------------------------------------
'     Initial Delay                 0.25  0.50  0.75  1.00
'     30 characters per second       00    20    40    60
'     16 characters per second       07    27    47    67
'      8 characters per second       0F    2F    4F    6F
'      4 characters per second       17    37    57    77
'      2 characters per second       1F    3F    5F    7F

'     Note: All values are shown in hexadecimal
'  ---------------------------------------------------------------------------
Hey Na_th_an, if I shouldn't use INKEY$ then what would be the &HD3 or whatever equivallent to the arrow keys?
Look in QB help, in the section called "keyboard scancodes". All that you have to do is read port &H60, it will return a scancode. The list is in hexadecimal, so you need to append &H to the number. For example, this loops ends when CTRL is pressed:

Code:
WHILE INP(&H60)<>&H1D
   dummy$=INKEY$ ' clears buffer
WEND
I don't like -that- much the inp(96) solution. Sometimes something happens:

http://forum.qbasicnews.com/viewtopic.ph...&start=166
fast keyrate:

Code:
OUT &H60, &HF3
SLEEP (1)
OUT &H60, 0
Quote:I don't like -that- much the inp(96) solution. Sometimes something happens:

http://forum.qbasicnews.com/viewtopic.ph...&start=166

I'm aware, I suggested a keyboard handler better. But people are really reticent to keyboard handlers... Obscure Sedlaceck's art...
Pages: 1 2