Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SalviaSage/9a3770a6e0e647761a7285c687644e01 to your computer and use it in GitHub Desktop.

Select an option

Save SalviaSage/9a3770a6e0e647761a7285c687644e01 to your computer and use it in GitHub Desktop.
A Scientific Study on the Keyboard

A Scientific Study on the Keyboard

https://typetimer.netlify.app/
https://joltfly.com/keyboard-keys-latency-test/
https://joltfly.com/keyboard-scan-rate-test
https://joltfly.com/mouse-latency-test/
https://monkeytype.com/

This document details the scientific study I made on the keyboard, and keyboard settings.
It concerns keypresses and other details.

"Double tapping" a key is a method where if a key is pressed again in a set duration, a trigger happens.
double tapping a key on a keyboard are as follows:

8ᵗʰ of a second is 125 milliseconds, this is the starting point for taps.
9ᵗʰ of a second is 111 milliseconds, this is a good average between accidental triggers and not triggering.
10ᵗʰ of a second is 100 milliseconds, this will miss for slow typists and people who can not double‑tap fast enough.

Syntax Examples using AutoHotkey;
if (A_PriorHotkey == "*CapsLock Up" and A_TimeSincePriorHotkey <= 125)
if (A_PriorHotkey == "*CapsLock Up" and A_TimeSincePriorHotkey <= 111)
if (A_PriorHotkey == "*CapsLock Up" and A_TimeSincePriorHotkey <= 100)

What this code does is that it waits for the second key to be pressed 100 milliseconds from the press of the first key. It does not expect the typist to hit two keys within 100 milliseconds, it expects the typist to hit one more key from the press of the first key to trigger a condition. This is similar to the double-click function that exists with the mouse.

"Holdables" is a key press method where we hold down a specific key on the keyboard for a set duration, then a trigger happens.
The best timings for holding a key on a keyboard are as follows:

3ʳᵈ of a second is 333 milliseconds, this is the starting point for holds.
4ᵗʰ of a second is 250 milliseconds, this is a good average between accidental triggers and not triggering.
5ᵗʰ of a second is 200 milliseconds, it should never be faster than this to prevent accidental triggers.

200 milliseconds have to be used if the "repeat delay" is set to the 4ᵗʰ increment (the fastest) at "keyboard Properties".
200 and 250 milliseconds can be used if the "repeat delay" is set to 333 milliseconds utilising the computer program "keyrate".
200, 250, and 333 milliseconds can be used if the "repeat delay" is set to the default 3ʳᵈ increment at "keyboard Properties".

The duration for which the keys are held during regular tapping of the keyboard (typing) varies, but typically does not exceed about 133 milliseconds (7.5ᵗʰ of a second). For this reason, the keyboard "repeat delay" should not be set to a speed faster than 7ᵗʰ of a second which is 143 milliseconds or 150 milliseconds if we round it up. A setting of a fast "repeat delay" can be useful in spamming keys. For example, unit creation in RTS games. Otherwise, it is too fast for typing words.

From the above example, we can see that double taps work faster than holdables, so if we are interested in trigger speed, this is the superior option. But, regardless, for typing purposes, holdables are the safer option, and that is the method I use for my "typer helper" program.

If a human tries to press a key as fast as possible repeatedly, he cannot beat about 10 times per second. That is keypresses with 100 milliseconds intervals. It is the same speed for the mouse button presses as well.

On the fastest Windows setting, the computer averages at 33.5 milliseconds. I suggest not instructing a machine to send keys faster than 33 milliseconds.

Keyboard Delay;

Open the run window (Win Key + R) and type "control keyboard".

When we hold down a key on the keyboard, it does not spam‑send that key. It sends the key once and waits a set amount of time before repeatedly sending it again. The "repeat delay" is the delay between the first send and the consecutive sends. On the default setting, the third setting, it is set at 500 milliseconds. The first selection is 1000 milliseconds (1 second). The second selection is 750 milliseconds. The third selection is 500 milliseconds. The fourth selection is 250 milliseconds, which is the fastest setting.

The default setting is good and does not require a modification for ordinary typists. However, if you want to be able to delete words a little faster and want more speed and response from your keyboard, you can select the fourth selection at 250 milliseconds. I think 333 milliseconds is also a good option, especially for doing holds at 250 milliseconds. However, 333 milliseconds cannot be set at this window.

The "repeat rate" setting has 32 increments. By default, it is at the fastest selection, the last selection. This setting controls how quickly and repeatedly the keys are sent when held down. That is, after the first initial delay, as discussed above. On the default fastest selection, the delays between sends are between 25 and 41 milliseconds with an average of 33.5 milliseconds. This is the reason that spam send commands should not exceed 33 milliseconds in computer programming.

At the mid setting, the 16ᵗʰ increment, the delays between sends are 58 to 75 milliseconds, with an average of 66.5 milliseconds.

At the slowest setting, the delays between sends are 500 milliseconds.

The "cursor blink rate" setting has 12 increments and the default setting is at the 8ᵗʰ increment. The first setting makes the blinker not blink at all. This only works on Windows File Explorer, Windows Notepad and some other internal elements. On some third‑party programs, this setting does not change anything. I recommend not modifying this setting or setting it at the 10th increment so it blinks faster.

Windows Registry;

DEFAULT SETTINGS, WINDOWS 11 24H2:

[HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response]
"AutoRepeatDelay"="0"
"AutoRepeatRate"="0"
"BounceTime"="0"
"DelayBeforeAcceptance"="0"
"Flags"="122"
"Last BounceKey Setting"=dword:00000000
"Last Valid Delay"=dword:00000000
"Last Valid Repeat"=dword:00000000
"Last Valid Wait"=dword:000003e8

I tried changing the "AutoRepeatDelay"="0" to "AutoRepeatDelay"="333" but it did not change it to 333 milliseconds. It was still the setting as set in "Keyboard Properties".

Changing "Flags"="122" to "Flags"="59" disabled the repeat altogether, meaning the keys do not spam upon being held down. To send it again, you have to press the key again.

Modifier Keys;

Modifier keys are not toggle keys. They release when they stop being pressed. However, I observed that sometimes they become stuck. In this case, I found that pressing both the left modifier key and the right modifier key several times together can cause the keys to become unstuck. For example, if the Shift key is still held down after letting go, you can press the left and the right Shift keys together several times to "unstick" the Shift key. The same is true for the Control and the Alt keys as well.

The Fn key (function key) is a modifier key that is found in some laptops and is supposed to be combined with other keys similar to the Ctrl and Alt keys. Its purpose is being able to press the top row function keys by pressing the fn‑key and then pressing the top row number keys from (1) to (=) key on keyboards that do not have a separate row of function keys, such as some laptop keyboards. This is also how function keys are pressed using the On‑Screen Keyboard (OSK).

AltGr (AltGraph) is a modifier key that is an extra modifier key. Typically, it replaces the right Alt key on certain keyboard layouts, but it is not found in the US keyboard layout where there is another Alt key instead. Hitting Ctrl + Alt also gives us the AltGr key on keyboards where there is AltGr. I introduce AltGr in my keyboard layout "US Plus".
https://en.wikipedia.org/wiki/AltGr_key
https://github.com/SalviaSage/Keyboard-Layouts/tree/master/Latin%20Utility%20Typers/US%20Plus%20Typer

One thing that I came up with was an idea to turn the Caps Lock key into a modifier key by making it holdable instead of its default toggle function. This meant that I would have a convenient extra modifier key above the Shift key for repurposing the Caps Kock key for alphabets that are unicameral (making no distinction between upper and lower case, but rather having only one case). This program can be found here:
https://github.com/SalviaSage/Autohotkey-Scripts-Repository/tree/master/Typing%20Scripts/Holdable%20CapsLock

Toggle Keys;

Toggle keys are different than modifier keys in the sense that you turn them on or off (toggle). During my testing, I saw that Num Lock is the only toggle key that preserves through restarts and shutdowns. I saw that the Num Lock toggle state is memorised by Windows and set accordingly after logging in to Windows. The BIOS screen turns Num Lock on. Caps Lock and Scroll Lock turn off and do not come back on through a restart or a shutdown. This is an appropriate behaviour that does not need modification. Using the third‑party program called "NumLocker" we can make it so that Caps Lock, Num Lock, and Scroll Lock toggle on or off at Windows boot. We can also lock the key states and prevent them from being changed from the "NumLocker" menu. This program is an AutoHotkey program and can be found here:
https://numlocker.en.softonic.com/

There are at least three other toggle keys that are typically not present on keyboards. These are called "Kana", "Roya", and "Loya". They are found on some Japanese keyboards. Programmatically, they exist, but there isn't a way to turn these on or off unless you know computer programming. A computer programmer can introduce these toggle keys into the keyboard layout, the same the AltGr key can be introduced. They can also be set to be used as hold keys instead of toggle keys. I successfully used these extra toggle keys when making a computer program for typing the Khmer alphabet.

Miscellaneous Information on Keys;

There are 104 keys on a full‑size ANSI‑104 keyboard. There are 17 keys on the number pad (numpad), on the right side of the keyboard. Without the numpad, we have 87 keys. There are keyboard specifications where the numpad is excluded such as in laptops, to conserve space. All of the numbers and the characters on the numpad are also present on the left side of the keyboard. So, if the keyboard does not have a numpad, it doesn't actually miss any keys. The purpose of the numpad is to enter numbers, decimal spaces and the four arithmetic operators in a quick and easy way. The numbers are also located on the top row of the keyboard. Above the top row number keys, there are function keys. Although keyboards typically come with 12 function keys, there are 24 function keys in total. On my "US Plus" keyboard layout, I made it so that the function keys from F13 to F24 can still be pressed on a regular, 12 function key keyboard by pressing Ctrl+Shift+F1 to F12. There are also keyboards where all 24 function keys are present. A full‑size keyboard with 24 function keys should have 116 keys in total, and if it doesn't have a numpad, 99 keys. There are also media keys on some keyboards that typically control things like video playback, stop, and volume controls. On some keyboards, there is a "game mode" button that disables and enables the Windows key.

Next to the right control key, there is a menu key, sometimes called "fn key". Its purpose is to open the drop menu or the right click context menu that many programs have. There is a "pause‑break" key on keyboards. There are actually two different keys here programmatically. By default, we press the pause key and if we hit Ctrl+Pause, we press the "break"(cancel) key. The pause key is supposed to pause or suspend programs while the break key serves a purpose similar to the escape key, albeit it is a key that is very rarely used. There is also a sleep button which is not present on all keyboards.

Multimedia Keys;

There are 18 multimedia keys. A list of which is as follows:

Multimedia Key Function
Browser_Back Back
Browser_Forward Forward
Browser_Refresh Refresh
Browser_Stop Stop
Browser_Search Search
Browser_Favorites Favorites
Browser_Home Homepage
Volume_Mute Mute the volume
Volume_Down Lower the volume
Volume_Up Increase the volume
Media_Next Next Track
Media_Prev Previous Track
Media_Stop Stop
Media_Play_Pause Play/Pause
Launch_Mail Launch default e-mail program
Launch_Media Launch default media player
Launch_App1 Launch This PC (formerly My Computer or Computer)
Launch_App2 Launch Calculator

Insert and Override modes;

Normally, the keyboard operates in the "insert" mode. If you hit the "insert" key on the keyboard, you will switch to the "override" mode and it writes over the other letters. It works like that in programs like "Notepad" and "Notepad++". If you accidentally turn on the "override" mode, you just have to hit the "insert" key to go back to normal operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment