remap mouse clicks to keypresses, or vice versa?

Anyone know of a way to remap specific keypresses to mouse
clicks, or remap mouse clicks to keypresses?

Specifically, I'd like to make the mouse wheel generate up/down
key events for all windows with "vim" in the title.

I can remap keys to other keys, but haven't had much luck with
mouse events.  Any hints?

FWIW, I've got this code for doing key remapping...

(define-match-window-setter 'keymap-trans
    (lambda (w prop value)
      (declare (unused prop))
      (let ((keymap (or (window-get w 'keymap)
                        (window-put w 'keymap (copy-sequence window-keymap)))))
          (lambda (pair)         ; pair of from and to keys
              keymap (car pair)
              (lambda () (interactive)
                (synthesize-event (lookup-event (cadr pair)) (input-focus)))))

;; remap some keys:
(add-window-matcher 'WM_CLASS "Xchat/xchat"
                    '(keymap-trans . (("C-f" "Right") 
                                      ("C-l" "C-f"))))
(add-window-matcher 'WM_CLASS "Dillo"
                    '(keymap-trans . (("M-Left" "BackSpace") 
                                      ("M-Right" "S-BackSpace"))))

-- Scott

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]