Function: ghostel-send-next-key

ghostel-send-next-key is an interactive and natively compiled function defined in ghostel.el.

Signature

(ghostel-send-next-key)

Documentation

Read the next key event and send it to the terminal.

This is an escape hatch for sending keys that are normally intercepted by Emacs (e.g., interrupt or prefix keys). Uses read-event so that prefix keys return immediately instead of waiting for a continuation keystroke. The event goes through the terminal's key encoder, so a child that enabled the kitty keyboard protocol receives the protocol-correct sequence.

Key Bindings

ghostel-mode-map C-c C-q ghostel-semi-char-mode-map C-q

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
;;; Key sending

(defun ghostel-send-next-key ()
  "Read the next key event and send it to the terminal.
This is an escape hatch for sending keys that are normally
intercepted by Emacs (e.g., interrupt or prefix keys).
Uses `read-event' so that prefix keys return immediately instead
of waiting for a continuation keystroke.  The event goes through
the terminal's key encoder, so a child that enabled the kitty
keyboard protocol receives the protocol-correct sequence."
  (interactive)
  (let* ((event (read-event "Send key: "))
         (spec (ghostel--event-key-spec event)))
    (ghostel--on-user-input)
    (cond
     (spec
      (ghostel--send-encoded (car spec) (cdr spec)))
     ;; Non-ASCII character without modifier bits — send as UTF-8
     ((and (integerp event) (< event #x400000))
      (ghostel--send-string (encode-coding-string (string event) 'utf-8)))
     (t (message "ghostel: unrecognized key %S" event)))))