how to proxy key presses

Elfalem

How can I build a component that sits between the keyboard and applications that captures all key presses and emits it's own key press signals. The emitted signals won't necessarily be 1-to-1 with those captured. Ultimately, I'm attempting to create an input method similar to ibus (I'd also appreciate information on how ibus works technically).

After reading this question, I think the appropriate place to capture would be after keycodes or keysymbols are generated. I also understand X allows a client to grab all keyboard events which sounds relevant to what I'm trying to do.

dirkt

There are basically two ways:

1) On the kernel level, find the /dev/input device that produces your keypresses, open it and do a "grab"-ioctl (same as evtest --grab does). That will cause this input device to send the key events exclusively to your application. Then use /dev/uinput to create your own input device from your application, where you can send key events out. X should connect to that device automatically.

2) On the X level, intercept keypress events just like the window manager does, and send out your own events with XSendEvent instead. I am not sure a grab would be the best way to do it; grabs are intended for a situation when some application temporarily wants to intercept all events during a specific interaction.

I have no idea what ibus does (maybe even a third method), I haven't looked at it in detail.

Edit

Had to look this up, because it's too long that I read about all the X details.

There are two basic grab functions: XGrabKeyboard, which generates FocusIn and FocusOut events, and takes complete control of the keyboard (active grab). This is the function I meant when talking about X grabs above, and this is the function that should only be active temporarily.

There is also XGrabKey, which registers a passive grab for specific keycodes. Looking very quickly at the source code of the window manager fvwm, this seems to be what the window manager uses.

The details of this are complicated enough that you probably want to dig up some documentation about how to program a window manager (or read source code, maybe even ibus source code).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to detect global key presses

From Dev

How to catch key presses in editable QTableWidgetItem?

From Dev

How to get realtime key presses in Assembly?

From Dev

How to detect 3 key presses in SWT KeyListener

From Dev

How to check for variable key presses in pygame

From Dev

How do determine key presses in C++

From Dev

How to count how many times a user presses a key in a given time

From Dev

android-how to detect key presses from a Service?

From Dev

How to programmatically simulate arrow key presses in Java FX

From Dev

How can I catch 2+ key presses at once?

From Dev

How to sense multiple key presses with Racket's `big-bang`

From Dev

How to simulate two consecutive ENTER key presses for a command in a bash script?

From Dev

How to get composite key presses using C language

From Dev

How can I emulate key presses on Vim startup?

From Dev

How to get composite key presses using C language

From Dev

How to have an event trigger every time a user presses a key in javascript

From Dev

How can I store key presses into variables to refactor this code?

From Dev

How can I map repeated key presses to specific?

From Dev

how to replace input numbers with commas after key presses

From Dev

Binding key presses

From Dev

Binding Keyword for Key Presses

From Java

Detecting arrow key presses in JavaScript

From Dev

Greasemonkey script to intercept key presses

From Dev

Detecting continuous key presses with UIKeyCommand

From Dev

Simulate multimedia key presses in Delphi

From Dev

Read individual key presses in PowerShell

From Dev

Multiple key presses in one case

From Dev

Greasemonkey script to intercept key presses

From Dev

Update a string based on key presses

Related Related

HotTag

Archive