Emacs Keys: Set Key to Insert Unicode Emoji
By Xah Lee. Date: . Last updated: .
Set a key to insert unicode char
Here's the best way to set a key to insert Emoji: Faces 😄 or Unicode: Math Symbols π2 ∞ ∫ .
put this in your Emacs Init File:
;; F8 insert bullet char (define-key key-translation-map (kbd "<f8>") "•")
Here's how to set a key sequence to insert different Unicode characters.
;; set keys to insert math symbol (define-key key-translation-map (kbd "<f5> p") "φ") (define-key key-translation-map (kbd "<f5> x") "ξ") (define-key key-translation-map (kbd "<f5> i") "∞") (define-key key-translation-map (kbd "<f5> <right>") "→") ;; set keys to insert emoji (define-key key-translation-map (kbd "<f5> 1") "😅") (define-key key-translation-map (kbd "<f5> 2") "❤")
🛑 WARNING: Problem Using global-set-key
You could also use global-set-key, but it has problems.
;; this won't work when in isearch (global-set-key (kbd "<f8>") (lambda () (interactive) (insert "→")))
When you do interactive search Ctrl+s, then when you type your key, it'll exit the search instead of inserting the char.