Typing Speed Test

Do we want to partake in competition again?

------
Reference:
https://cplusplus.com/forum/lounge/279014/

I found that the code we used last time wasn't working anymore. "using namespace std;" had to be removed for ambiguity, and the "waitforkeypress" function would instantly return thinking a key was pressed.
------

So here's some new code we can use to battle.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <string>
#include <chrono>
#include <Windows.h>

using namespace std;
using namespace std::chrono;

void waitforkeypress()
{
    HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
    INPUT_RECORD inputRecord;
    DWORD events;

    if (hInput == INVALID_HANDLE_VALUE) return;
     
    while (true)
    {
        WaitForSingleObject(hInput, INFINITE);
        if (PeekConsoleInput(hInput, &inputRecord, 1, &events) && inputRecord.EventType == KEY_EVENT && inputRecord.Event.KeyEvent.bKeyDown) return;
        else ReadConsoleInput(hInput, &inputRecord, 1, &events);
    }
}

int main() {
    string input;
    const string target = "abcdefghijklmnopqrstuvwxyz";

    while (true)
    {
        cout << "Type the alphabet (a-z) as quickly as possible, then press Enter:\n";

        waitforkeypress();
        // Start high-precision timer
        auto start = high_resolution_clock::now();

        getline(cin, input); // Read input from the user

        // Stop the timer
        auto end = high_resolution_clock::now();

        // Calculate the elapsed time in milliseconds
        auto duration = duration_cast<milliseconds>(end - start);

        // Ensure the user typed the alphabet correctly
        if (input == target) {
            cout << "Congratulations! You typed the alphabet in " << duration.count() << " milliseconds.\n";
        }
        else {
            cout << "Alphabet was incorrect. It took you " << duration.count() << " milliseconds.\n" << "Please try again.\n";
        }
    }
}



Type the alphabet (a-z) as quickly as possible, then press Enter:
abcdefghijklmnopqrstuvwxyz
Congratulations! You typed the alphabet in 3967 milliseconds.


I could perhaps do better, but good enough until I have a worthy opponent!

EDIT: if you're not on Windows, unlucky. Feel free to put up some altered code that would work for any OS!
Last edited on
I'll battle with myself then I guess.. :(

Type the alphabet (a-z) as quickly as possible, then press Enter:
abcdefghijklmnopqrstuvwxyz
Congratulations! You typed the alphabet in 3498 milliseconds.
You're fast! I got 5061 after about 10 tries :(
5061
4307
Last edited on
Oh nice! You're getting better 😎

I keep trying to hit around 2900ms but I always end up with a mistake or two. After 5 or so minutes I can't even type the alphabet correctly anymore lmao.
I’ve never been good at these kinds of things. I can type actual words quickly enough, but something artificial like the alphabet I just can’t do (and don’t care to practice to improve) better than five seconds or so.
It always feels like I'm typing everything wrong when I'm doing the alphabet, think its because we know how to spell out other words but the alphabet is just too long to be able to do that without having to repeat the song in my head.

I'd be able to hit around 2800ms or less (I got 2600ms with two small errors), but the "M" key is so easy to miss!
A speed typing "challenge" is rather a losing proposition for me, increasing arthritis and such. Being an geriatric ol' fart.

I personally prefer to be as much as possible an accurate typist vs. a speedy one anyway.

The speed also depends upon the type of keyboard used and whether you can touch type or not.
It blows my mind that so many people cannot touch type.
I tried to teach my dad how to touch type but he never took the time to practice it. Which is unfortunate because he doesn't have the best vision...

Typing the alphabet seems more or less artificial to me, but let me try it out.

> Congratulations! You typed the alphabet in 8689 milliseconds.
> Congratulations! You typed the alphabet in 6321 milliseconds.
> Congratulations! You typed the alphabet in 8207 milliseconds.
> Congratulations! You typed the alphabet in 7753 milliseconds.
> Congratulations! You typed the alphabet in 7295 milliseconds.
> Congratulations! You typed the alphabet in 7287 milliseconds.
> Congratulations! You typed the alphabet in 6384 milliseconds.
> Congratulations! You typed the alphabet in 5711 milliseconds.
(Incorrect tries removed for brevity and to avoid embarrassment.)

I definitely could get faster if I got the muscle memory down, but that feels like cheating. I think it takes me longer than others to get muscle memory down, but once I do I can usually be pretty accurate (e.g. learning a song on piano).
It blows my mind that so many people cannot touch type.


My old school started touch-typing (using a manual typewriter) lessons for those aged 15 - 16 who were not academically inclined when I entered sixth form. The few of us (three) doing A-level computer science were encouraged to attend. I've never regretted this - although with age I'm not as quick/accurate as I was.

> Congratulations! You typed the alphabet in 2963 milliseconds.
> Congratulations! You typed the alphabet in 2963 milliseconds.
Nice PR!
abcdefghijklmnopqrstuvwxyz
Congratulations! You typed the alphabet in 3122 milliseconds.
abcdefghijklnopqrstuvwxyz
Alphabet was incorrect. It took you 2786 milliseconds.


I swear I just keep missing that stupid M key. My low profile keyboard is better for gaming though I love it for typing (just easier to make mistakes).

I could definitely go down to 2600ms if I practiced I feel
abcdefghijklnopqstuvwyxz
Alphabet was incorrect. It took you 2326 milliseconds.


I just missed "M" and "R". I'm gonna stab myself. Anyway, that's enough mindless alphabet typing.


EDIT: got curious and looked at the world records, apparently the record is 1090ms 👀 (without spaces obviously)
Last edited on
Topic archived. No new replies allowed.