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

前端 未结 15 1789
攒了一身酷
攒了一身酷 2021-01-29 21:16

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

相关标签:
15条回答
  • 2021-01-29 21:40

    Visual Assist has an option to double your effective key movements in Visual Studio which I use all the time.

    0 讨论(0)
  • 2021-01-29 21:43

    I do like to work on the keyboard alone. Why? Because when you use the mouse you have to grab it. A time loss.

    On the other hand sometimes it seems that every application has its own keyboard type-rates built in. Not to speak from BIOS-properties or OS-settings. So I gathered shortkeys which can be pretty fast (i.e. you are faster typing Ctrl + right(arrow)-right-right than keeping your finger on the right(arrow) key :).

    Here are some keyboard shortcuts I find most valuable (it works on Windows; I am not sure about OS X):

    ctrl-right: Go to the end of the previous/the next word (stated before)
    ctrl-left:  Go to the beginning of the previous/the word before (stated before)
    ctrl-up:    Go to the beginning of this paragraph
                (or to the next paragraph over this)
    ctrl-down:  Go to the end of this paragraph
                (or to the next paragraph after this)
    ctrl-pos1:  Go to the beginning of the file
    ctrl-end:   Go to the end of the file
    

    All these may be combined with the shift-key, so that the text is selected while doing so. Now let's go for more weird stuff:

    alt-esc:     Get the actual application into the background
    ctrl-esc:    This is like pressing the "start-button" in Windows: You can
                 navigate with arrow keys or shortcuts to start programs from here
    ctrl-l:      While using Firefox this accesses the URL-entry-field to simply
                 type URLs (does not work on Stack Overflow :)
    ctrl-tab,
    ctrl-pageup
    ctrl-pagedwn Navigate through tabs (even in your development environment)
    

    So these are the most used shortcuts I need while programming.

    0 讨论(0)
  • 2021-01-29 21:44

    For Windows, open regedit.exe and navigate to HKEY_CURRENT_USER\Control Panel\Keyboard. Change KeyboardSpeed to your liking.

    0 讨论(0)
  • 2021-01-29 21:46

    Don't navigate character-by-character.

    In Vim (see ViEmu for Visual Studio):

    • bw -- prev/next word
    • () -- prev/next sentence (full stop-delimited text)
    • {} -- prev/next paragraph (blank-line delimited sections of text)
    • /? -- move the cursor to the prev/next occurence the text found (w/ set incsearch)

    Moreover, each of the movements takes a number as prefix that lets you specify how many times to repeat the command, e.g.:

    • 20j -- jump 20 lines down
    • 3} -- three paragraphs down
    • 4w -- move 4 words forward
    • 40G -- move to (absolute) line number 40

    There are most likely equivalent ways to navigate through text in your editor. If not, you should consider switching to a better one.

    0 讨论(0)
  • 2021-01-29 21:47

    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;
    }
    
    0 讨论(0)
  • 2021-01-29 21:47

    I'm using KeyboardKing on my PC. It's freeware and it can increase the repeat rate up to 200 which is quite enough. I recommend to set the process priority to High for even smoother moves and less "repeat locks" which happen sometime and are very annoying. With high priority, it works perfectly.

    No one understands why we navigate by arrows. It's funny.

    0 讨论(0)
提交回复
热议问题