First, I set up
.Xmodmapso that pressing Caps Lock is interpreted as the same as pressing Calculator key on my multimedia keyboard. I chose Calculator key because it doesn’t currently do anything, and I don’t use it at all. I added the following lines to my
Now, pressing Caps Lock would be the same as pressing Calculator key.
remove Lock = Caps_Lock keysym Caps_Lock = XF86Calculator
We need to make pressing Calculator key send Ctrl+T keystrokes instead. This can be done in KDE by defining a new global shortcut. In KDE 4.7, this is done by navigating to System Settings > Shortcuts and Gestures > Custom Shortcuts. Define a new Command/URL global shortcut. Use Caps Lock as the trigger shortcut (it would show as Calculator in the UI). Specify
as the command to run. (You’d have to install xte if it isn’t already installed on your machine.) That’s it; now pressing Caps Lock anywhere within KDE would send Ctrl+T keystrokes instead.
/usr/bin/xte "keydown Control_L" "key t" "keyup Control_L"
A few tips:
- You can use
xmodmap -pkcommand to see the list of all available keys.
- Be sure to select a key that’s actually present on your keyboard; my laptop does not have a calculator key, so I am using the battery key instead. Any key that's present in the keyboard but not currently in use would do.
- After you have modified your
~/.Xmodmap, you’ll have to log out and log back in for the mappings to apply. Alternatively, you can apply the configuration to your current session from the command line, e.g. by running
xmodmap -e "remove Lock = Caps_Lock".