Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send special keys #1

Open
MarSoft opened this issue Feb 17, 2020 · 3 comments
Open

Send special keys #1

MarSoft opened this issue Feb 17, 2020 · 3 comments

Comments

@MarSoft
Copy link

MarSoft commented Feb 17, 2020

Is it possible to send some hotkey combination with this tool? Something like Control+Super+X. If yes then how to prepare the correct stdin input for the tool?

@piater
Copy link
Owner

piater commented Feb 17, 2020

No, but it can be easily implemented.

Your question already identifies the core issue :-) The output generation should be trivially extensible to all relevant modifier keys. For input, one possibility is to define an escape syntax for modifier and other special keys. However, I feel that this violates the spirit of this tool that essentially implements an inverse keymap. I'd prefer to support hotkey combinations by special command-line options. For example, echo a | uinputchars -C might emit a Control+a.

I'll consider patches or may even implement it myself someday if people want it.

@MarSoft
Copy link
Author

MarSoft commented Feb 23, 2020 via email

@piater
Copy link
Owner

piater commented Feb 23, 2020

Good point. Technically, function keys are also subject to keymap translation, as are modifier keys. So maybe the best course of action is an escape syntax after all. Since key press and key release events are emitted separately, one might separate the issues of literal vs. escaped input and key press vs release events. Thinking aloud, how about:

  • \: escape character
  • \\: literal backslash
  • \(: next token represents a key press event
  • \): key pressed at corresponding \( is released
  • \K_...: action code to be translated by inverse keymap to corresponding keycode KEY_... to be emitted
  • \KEY_...: keycode to be emitted, bypassing the inverse keymap
  • : terminates \K... tokens; can be omitted if next token is also escaped
  • any other character: character to be translated by inverse keymap
  • any token (other than \( and \)) not immediately preceded by \( results in a key press and a key release event in immediate succession

Examples:

  • Ctrl+F4: \(\K_CTRL\K_F4\)
  • The following result in the same emitted sequence: A, \(\K_SHIFTL a\), \(\K_SHIFTL\(a\)\)
  • To save the current file in emacs: \(\K_CTRL xs\)
  • To switch to VT 2: \(\K_CTRL\(\K_ALT\K_F2\)\)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants