Skip to content

syn-ce/entropy

Repository files navigation

keys pressed!

(This number updates regularly)

Entropy

I spend a lot of time in front of a computer, doing very important stuff (like writing questionable code). A substantial share of that time is devoted to thinking about what to type, and a little less is then spent actually typing it. However, I have to wonder: What am I actually typing all the time?

Let's start with a brief detour to the entire realm of possible input events we are facing. To get a baseline, we can consider all input events which are mapped by the Linux kernel. For our purposes we'll use the evdev python library, which among other things exposes these integer constants.

We are quick to start suspecting that

import evdev

print(len(evdev.ecodes.keys))  # 596

596 (!) possible input events exceeds the number of keys on my laptop keyboard by a fair bit (it's got 81 in case you're wondering, and even my external full-size one doesn't sport more than 109). Granted, some of these (looking at the function keys) can cause different events, but even if we're being generous here, the number of keys we are nowhere near almost 600. Turns out this has a good reason: There are a lot more devices this has to work with, each providing different (methods of) inputs. Here are some of my favorites (some are mapped to multiple values):

For our purposes, it'll suffice to only consider the (types of) events of keys which were actually pressed in the regarded timeframe (since we are most interested in larger timeframes, say, at least days, most most of the more common keys will likely have been pressed anyway).

The fun part

I have been collecting information about what I hammer into my keyboards all day for the last couple of weeks now (I've done so using a way too complicated bloated piece of software I wrote in C a while back, capturing the events from /dev/input).

To get a sense of what we're working with, let's first plot the keys with their counts of a particular day:

Barchart displaying the counts of keys pressed on October 25th, 2024. Sorted by counts descending.

Phew. First of all, seems like I'm doing a lot of undoing. A whopping 8.4% of key presses on that day were devoted to deleting something. Second, that's a lot of keystrokes! In total, 60237 between 0 am and 12 pm. With the average english word length being 4.7 characters, that's closing in on 13000 words on a single day. At this pace it would take me around 90 days to type out all 8 books of the Harry Potter series.

Of course, this number gets bloated by backspace and other keys like shift and alt, which by themselves don't actually contribute any characters.

keys_to_exclude = ['backspace', 'leftshift', 'rightshift', 'leftctrl', 'rightctrl']
print(sum([count for key, count in key_frequencies.items() if key not in keys_to_exclude]))  # 48585

With these not considered, we're closer to around 50000 characters on that day.

If we only look at the letters (excluding the German Umlaute ä, ö and ü as well as ß) we get the following distribution:

Barchart displaying the relative frequency of letters (i.e., their corresponding keys) on October 25th, 2024. Sorted by frequency descending.

Comparing it to the relative letter frequency in the english language

Barchart displaying the relative frequency of letters (i.e., their corresponding keys) on October 25th, 2024. Sorted by frequency descending. Also contains bars for the relative frequencies of letters in the english language.

we see that there are some diversions, giving away that I like to use Vim keybindings (look at w, b, k, j).

Looking again at the first graph, it includes the raw keystrokes, i.e., it doesn't apply the modifiers (Shift, AltGr). If you've been wondering why I seem to be liking the 8 and 9 quite a bit, it's because on the German QWERTZ layout these are the keys which house the square brackets (when combined with Shift). After applying the Shifts and AltGrs we get the following:

Barchart displaying the relative frequency of letters (i.e., their corresponding keys) on October 25th, 2024, after having applied modifier keys (Shift, AltGr). Sorted by frequency descending.

[To be continued]

About

What I'm typing all day

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published