4

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.

4
  • 1
    I think you need at-least two keys for a shortcut. i.e, you can't set a shortcut with only one key win
    – user441517
    Jan 6, 2016 at 16:57
  • 2
    @VishwaPrakashHV you can, other example, you can take screenshot with single print key. Well, take other example with two keys. Ctrl + Alt assigned to one shortcut. Now I want Ctrl + Alt + A-Z to other shortcut(s). ??
    – Ravan
    Jan 7, 2016 at 3:28
  • Well you cannot set only Ctrl+Alt as shortcut to any task. i.e, You cannot set any shortcuts using only the combinations of Ctrl or Alt or Super or Shift. And also You need at-least one of these Keys to set any Shortcuts. (I am curious if you get any working combination with real problem mentioned in the question)
    – user441517
    Jan 7, 2016 at 7:21
  • 1
    why not? you can, for example change text entry settings shortcut to Ctrl + Shift from Win + Space @VishwaPrakashHV
    – Ravan
    Jan 7, 2016 at 7:28

1 Answer 1

1

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 keystrokes AutoKey emits and won't even know that you didn't type them. (There are some fine points to this, but it mostly just works.)

Not the answer you're looking for? Browse other questions tagged .