I am using Ubuntu 14.04. with Unity DE.
How can I make keyboard shortcuts work on key release, not on key press?
For example, if I want to use the windows key for multiple shortcuts, it works only for the one that's triggered by the win key alone, because the shortcut works before the next key press is registered.
Not exactly an answer, but maybe a solution.
AFAIK, the keys you mention are modifier keys which are intended to modify the effect of another (non-modifier) key being pressed simultaneously.
I'm not very well versed in hardware, but I believe some of the modifier processing may actually occur in the keyboard hardware or in the drivers - so they're not easily accessible at the application level. I know that some keyboards I had many years ago put out 8-bit ASCII characters and actually modified some of those bits when you pressed Ctrl or shift.
That being said, running
xev
shows that "higher level" software can get access to the actual scan codes coming out of the keyboard "device", so I expect that it is possible to write your own replacement keyboard driver which will do anything you are skilled enough to code, but doing that might involve a lot of knowledge of the kernel and other internals of Linux.Instead of growing hair on your eyeballs learning all of that stuff, first consider a few alternatives that may serve some or all of your needs:
The
xmodmap
command allows you to alter your keyboard layout by changing what individual keys do. This takes place before any applications see the keystrokes, so it should work transparently.AutoKey
is a keyboard macro processor which allows you to define text phrases and hotkeys which trigger phrase substitutions or run entire macros written in Python.It is designed for use in gui environments which are supported by either GTK or QT, but also will work fine in a terminal window.
Each macro or phrase can also have an associated window filter so that it will only work in windows which pass the filter (and not do inappropriate things if invoked in a window which it was not designed to work in.)
Once a macro is invoked, you're essentially running a Python program which can do almost anything Python is capable of - limited primarily by your programming skills - because there are Python modules for almost anything you might want to accomplish.
Since
AutoKey
is designed to emit keystrokes that look exactly as if you typed them, it should work with almost any program. The program will just think you typed whatever keystrokesAutoKey
emits and won't even know that you didn't type them. (There are some fine points to this, but it mostly just works.)