Create superscript by keyboard shortcut without going into the superscript environment

Guess I’m being too lazy here… For example, I want that after typing Alt-z a square (^2) will be inserted without the cursor going into the superscript.

I guess this can be realized by including a cursor movement in the keyboard shortcut (moving the cursor to the right once) but I don’t know how to do it…

OK, I got it worked. It’s

(kbd-map
  (:mode in-math?)
  (:require (not (in-variants-disabled?)))
  ("A-z" (insert '(rsup "2"))))
2 Likes