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.
------
#include <iostream>
#include <string>
#include <chrono>
#include <Windows.h>
usingnamespace std;
usingnamespace 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!
Type the alphabet (a-z) as quickly as possible, then press Enter:
abcdefghijklmnopqrstuvwxyz
Congratulations! You typed the alphabet in 3498 milliseconds.
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!
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.
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