Next: , Previous: , Up: Miscellaneous  

Q5.1.2: Can I generate "fake" keyboard events?

I wonder if there is an interactive function that can generate fake keyboard events. This way, I could simply map them inside SXEmacs.

This seems to work:

(defun cg--generate-char-event (ch)
  "Generate an event, as if ch has been typed"
  (dispatch-event (character-to-event ch)))

;;  Backspace and Delete stuff
(global-set-key [backspace]
  (lambda () (interactive) (cg--generate-char-event 127)))
(global-set-key [unknown_keysym_0x4]
  (lambda () (interactive) (cg--generate-char-event 4)))