Logkeys is a keyboard logger for Linux. You can install logkeys by following the instructions on the logkeys installation page.
The following has been performed with the following versions:
Run the following command to check that
logkeys is properly installed:
The previous command should display help page.
The following command will display each input device details:
I'm not fully sure, but I think the first device displayed is
second one is
/dev/input/event1 and so one.
Be carrefull if you have several keyboards to pick the right one. In my case, I have
a desktop keyboard (
/dev/input/event5) connected to a laptop (
In the following, I will log the desktop keyboard on
The following command starts recording key pressed and stores the keys in the file
log-keyboard.txt located in my home directory:
sudo logkeys -s -o ~/log-keyboard.txt -d event5
Modify the previous command according to the right event file and path to the desired log file.
If you want a specific layout, you have to specify it with the
-m option. There is
a list of available keymaps on the logkeys repository.
If your keyboard is not in the list, you can create your own layout by following
the instructions on this page.
For example, if you want the French layout, download the French keymap and run the following command:
sudo logkeys -s -o ~/log-keyboard.txt -d event5 -m /path/to/file/fr.map
Since the command is launched with root permissions, only users with root permissions can display the log file. The following command display the log file with recorded keys inside:
sudo cat log-keyboard.txt
The following command stops recording the keys:
sudo logkeys -k