Results 1 to 2 of 2

Thread: Setting the Keyboard Delay.

Threaded View

  1. #1

    Thread Starter
    Member Maltonomy's Avatar
    Join Date
    May 2005
    Location
    New York
    Posts
    48

    Resolved Setting the Keyboard Delay.

    I'm making a test 2D rpg style game. Is there a way to decrease the keyboard delay? I have the directional keys set to WASD. Everything in project to work as it's supposed to, However I don't want that 'second' delay when you hit a key for it to begin repeating.

    *EDIT: got it (can't figure out how to delete this thread, maybe because its the first 1)
    VB Code:
    1. Private Declare Function SystemParametersInfo Lib "user32" Alias _
    2.         "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
    3.         ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
    4. Const SPI_SETKEYBOARDDELAY As Long = 23
    5. Const SPI_SETKEYBOARDSPEED As Long = 11
    6. Const SPIF_SENDWININICHANGE As Long = &H2
    7. Const SPIF_UPDATEINIFILE As Long = &H1
    8.  
    9. Sub SetKeyboardRepeatInfo(ByVal Delay As Long, ByVal Speed As Long, _
    10.     Optional ByVal MakePermanent As Boolean)
    11.     Dim flags As Long
    12.  
    13.     ' are these changes permanent?
    14.     If MakePermanent Then
    15.         flags = SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE
    16.     End If
    17.  
    18.     ' set the keyboard delay
    19.     SystemParametersInfo SPI_SETKEYBOARDDELAY, Delay, ByVal 0&, flags
    20.     ' set the keyboard repeat rate
    21.     SystemParametersInfo SPI_SETKEYBOARDSPEED, Speed, ByVal 0&, flags
    22. End Sub
    23.  
    24. ' set new values for keyboard speed and delay
    25. '
    26. ' DELAY is the timeout after which auto.repeat starts
    27. '       can range from 0 (250ms) to 3 (1 sec)
    28. ' SPEED is the speed of repeat rate
    29. '       can range from 0 (2.5 repetitions/sec) to
    30. '                 to 31 (about 30 repetitions/sec)
    31. ' If MAKEPERMANENT is True, then these new values persists among
    32. '    subsequent Windows sessions
    33.  
    34. 'USAGE
    35. 'SetKeyboardRepeatInfo(0,31,True)
    36. 'THAT WILL SET EVERYTHING ON FAST
    Last edited by Maltonomy; May 26th, 2005 at 09:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width