Lightweight Python tool to remap Ctrl + H/J/K/L to arrow keys and CapsLock to ESC — optimized for Dvorak users.
- Maps
Ctrl + Hto ←,Ctrl + Jto ↓,Ctrl + Kto ↑,Ctrl + Lto → - Remaps
CapsLocktoESC - Works by intercepting input events and forwarding them through a virtual keyboard
- Designed for Dvorak layout, but easily adaptable
I was using stewartpark/c-hjkl, but after reinstalling Arch Linux, it stopped working for my laptop’s built-in keyboard.
Since I’m not super familiar with Rust and wanted to debug it quickly, I reimplemented the core logic in Python.
- Detects connected keyboards on your system.
- Listens to their input events using
evdev. - Creates a virtual device using the
uinputmodule. - Translates your key combos and emits remapped events.
Your system receives input from the virtual keyboard instead of the physical one.
Yes.
To change the key used for triggering remaps (e.g., Ctrl to something else), edit:
# In src/keyboard_handler.py
KEY_LEFTCTRL = 29 # Change this to your desired keyYou can also modify other mappings by tweaking the keycode logic in the same file.
⚠️ IMPORTANT: Run and install this tool as therootuser only.Since it runs with elevated privileges and hooks low-level input devices, make sure that:
- Your normal user cannot modify the project files.
- You clone it into a protected directory (e.g.,
/opt/).
This prevents privilege escalation in case your user account gets compromised.
sudo su
cd /opt
git clone https://github.com/AlpSha/c-hjkl-py.git
cd c-hjkl-py
./install.sh- Python 3
evdevPython packageuinputkernel module (make sure it’s loaded)
Install evdev via pip if needed:
pip install evdev- Arch Linux (x86_64)
- Dvorak layout
- Layout support toggle
- GUI tray icon
- Hotkey customization via config file
MIT
Made with caffeine and key rage by Alp.