Skip to content

flightlessmango/xkbcat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xkbcat

X11 keylogger with simple output format: one line on stdout per key event.

Great as a data source for keyboard heatmaps, layout comparisons or screencasting applications.

<100 lines of modern C. Doesn't need sudo.

Examples

Given no flags, xkbcat prints only keypresses, one per line. Here's the output when I type "Hi":

Shift_L
h
i

With key-ups enabled (xkbcat -up), the format changes to show them:

+ Shift_L
+ h
- h
- Shift_L
+ i
- i

Lines starting + are key-downs; - are key-ups.

Left- and right-positioned modifier keys are recognised separately. The F-keys work too, as do most media keys like XF86AudioLowerVolume.

Compilation

Just make.

Don't have clang? Edit the makefile to use gcc.

Don't have X11/extensions/XInput2.h? Install your distro's libxi-devel package.

Usage

Flags you can pass (all optional):

  • -display <display>: set target X display (default :0)
  • -up: also prepend key-ups (default: don't)
  • -help: print usage hints and exit

Then just type as you would usually. Interrupt signal (C-c) to end.

Related programs

If you need to log keys across a whole Linux system (also in the framebuffer—not just in X11), try keysniffer. It works via a kernel module, and needs sudo.

If you want to see what characters the user actually typed (with modifier keys, backspace, etc resolved into text), xspy or logkeys might be better for you.

If you want to add timestamps to each line for logging purposes, I recommend piping to the moreutils package's ts. These answers feature various other tools good for the purpose.

Versioning

The git-tagged version numbers follow semver.

License

ISC.

About

simple sudoless X11 keylogger

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C 96.4%
  • Makefile 3.6%