# Capture X keystrokes

**URL:** <https://www.ruby-forum.com/t/capture-x-keystrokes/129174>\
**Category:** Ruby\
**Created:** [February 15, 2008, 3:09am UTC](https://www.ruby-forum.com/t/capture-x-keystrokes/129174 "2008-02-15T03:09:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuzb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kuzb](https://www.ruby-forum.com/u/kuzb)\
**Post date:** [February 15, 2008, 3:09am UTC](https://www.ruby-forum.com/t/capture-x-keystrokes/129174/1 "2008-02-15T03:09:31Z")

</div>

Hi,

I’m the author of Snippits[1], a text expansion program for Linux.  
Snippits types by generating X keystrokes, using the xte utility from  
the xautomation suite. However, the way xte reads typed X characters is  
a bit of a hack: it generates key commands to select back one word  
(ctrl+shift+left), cut (ctrl+x), and then it reads the clipboard (using  
xsel). This method is slow, error-prone, and ugly.

I was wondering if there was any way to capture X keystrokes as they are  
generated. Does anyone know of a better method than above? I’m not  
averse to using Ruby UI Toolkit bindings, if they have some method for  
this.

Does anyone have any suggestions?

1: [http://ben.kudria.net/code/snippits](http://ben.kudria.net/code/snippits)
