Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I increase the key repeat rate beyond the OS's limit?

I have a bad habit of using the cursor keys of my keyboard to navigate source code. It's something I've done for 15 years and this of course means that my navigating speed is limited by the speed of the keyboard. On both Vista and OS X (I dual boot a MacBook), I have my key repeat rate turned all the way up. But in Visual Studio, and other apps, the rate is still much slower than I would prefer.

How can I make the key repeat rate faster in Visual Studio and other text editors?

like image 642
Frank Krueger Avatar asked Oct 05 '08 01:10

Frank Krueger


People also ask

What is the default keyboard repeat rate?

However, for those that want to have more options, there's a second way to change your keyboard repeat rate from the default repeat rate of “31” in the computer's registry editor. What is this? To adjust the keyboard repeat rate between 0 and 31: Hold down Windows+R and type in “regedit” to open up the registry editor.


1 Answers

In Windows you can set this with a system call (SystemParametersInfo(SPI_SETFILTERKEYS,...)).

I wrote a utility for myself: keyrate <delay> <repeat>.

Github repository.

Full source in case that link goes away:

#include <windows.h> #include <stdlib.h> #include <stdio.h>  BOOL parseDword(const char* in, DWORD* out) {    char* end;    long result = strtol(in, &end, 10);    BOOL success = (errno == 0 && end != in);    if (success)    {        *out = result;    }    return success; }   int main(int argc, char* argv[]) {    FILTERKEYS keys = { sizeof(FILTERKEYS) };     if (argc == 1)    {       puts ("No parameters given: disabling.");    }    else if (argc != 3)    {       puts ("Usage: keyrate <delay ms> <repeat ms>\nCall with no parameters to disable.");       return 0;    }    else if (parseDword(argv[1], &keys.iDelayMSec)           && parseDword(argv[2], &keys.iRepeatMSec))    {       printf("Setting keyrate: delay: %d, rate: %d\n", (int) keys.iDelayMSec, (int) keys.iRepeatMSec);       keys.dwFlags = FKF_FILTERKEYSON|FKF_AVAILABLE;    }     if (!SystemParametersInfo (SPI_SETFILTERKEYS, 0, (LPVOID) &keys, 0))    {       fprintf (stderr, "System call failed.\nUnable to set keyrate.");    }     return 0; } 
like image 200
Mud Avatar answered Sep 18 '22 16:09

Mud