Binding keystrokes to keystrokes.


Results 1 to 2 of 2

Thread: Binding keystrokes to keystrokes.

  1. #1
    Join Date
    Dec 2002
    Location
    Ottawa, Ontario, Canada
    Posts
    86

    Binding keystrokes to keystrokes.

    I want to find a simple, quick, on the fly, way to bind a series of keystrokes to one keystroke. Below is this moments problem, but I have run into this before so I would like a methodology.

    Problem:
    FaceBook and other messaging programs remove excess spaces. That is fine for most posts, but occasionally I want to retain my columnar formatting. I am willing to insert a ctl-u unicode formula for space or tab if such can be found. I know I can send my data as an image, but I am looking for something that is quick and dirty that I can use on the fly. U+00a0 seems to solve my initial problem.

    Now I would like to bind <ctrl><shift>u00a0 <space> to one key and have it execute. -- <mod4, or Super, or Win>+SPACE would be nice, but any combination will do. How do I do this?
    Last edited by Bill Case; 06-23-2011 at 06:03 PM.
    Regards Bill
    Fedora 14, Gnome 2.32.2.1
    Evo.2.32, Emacs 23.2.1

  2. #2
    Join Date
    Sep 1999
    Location
    Cambridge, UK
    Posts
    509
    You can use xmacroplay. Some window managers will let you bind arbitrary keypresses to run commands (eg xmacroplay) but an alternative is to run xbindkeys in the background to listen for the keypress you want and have it launch xmacroplay to send the keys.

    One gotcha is that the keys you use in your xbindkeys trigger are still classed as pressed when your script runs so either you will have to do a sleep or have your script release the trigger key(s) first.

    Here I tell xbindkeys to call xmacroplay on the mao script when I press XF86Launch6 (which happens to be what xev told me was the result of pressing F15 on my Apple keyboard).
    Code:
    $ cat ~/.xbindkeysrc
    "xmacroplay $DISPLAY < ~/.xbindkeys/mao"
      XF86Launch6
    Here's the script:
    Code:
    $ cat ~/.xbindkeys/mao
    KeyStrRelease XF86Launch6
    KeyStrPress Control_L
    KeyStrPress Shift_L
    KeyStr U
    KeyStrRelease Shift_L
    KeyStrRelease Control_L
    KeyStr 8
    KeyStr C
    KeyStr 9
    KeyStr 3
    KeyStr space
    And I run
    Code:
    xbindkeys
    Here's a magic cat to prove it works:
    Code:
    By the way, xmacroplay is ancient and probably won't compile without help. I have an almost-equally-ancient binary kicking around but to recompile it on my Fedora 15 machine I had to create config.h with
    Code:
    #define HAVE_IOSTREAM
    using namespace std;
    then modify all g++ lines in the Makefile to include
    Code:
    -DHAVE_CONFIG
    Maybe your vendor has a package which will save you the hassle.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •