Emacs: Xah Fly Keys, Add Keys to Switch Mode
Add a Global Key to Activate/Toggle Command/Insert Mode
You can add global keys to activate command mode or insert mode, or add a key to toggle.
Normally, i recommend setting CapsLock key position to send Home, and it will activate command mode. But if you have a batman keyboard with lots thumb keys, or Foot Pedal you may want to add other keys to activate command mode, activate insert mode, or toggle them.
Note that, activate command/insert is something you have to do few times a minute. So, the ease of the key is the utmost important.
The key choices to “Activate/Toggle Command/Insert Mode” can be anything not used by Xah Fly Keys. The Ctrl + letter and Meta + letter spots are mostly empty. You can also use F1 to F24, and PageUp PageDown. Note, it should best be a single key press, not chord, because you'll need to call this command few times per minute.
Add a Global Key to Activate Command Mode
Here's a example of how to add a command mode activation key.
;; make the f4 key switch to command mode (global-set-key (kbd "<f4>") 'xah-fly-command-mode-activate)
Binding Escape key:
;; make the esc key switch to command mode, in GUI emacs only (global-set-key (kbd "<escape>") 'xah-fly-command-mode-activate) ;; WARNING: there are two different syntax for escape key: <escape> and ESC. ;; <escape> is effective in gui emacs only. ;; ESC is effective when running emacs in terminal. ;; Binding ESC may make arrow keys or f1 f2 keys not work, in text terminal, or in text terminal and running a remote emacs ;; because text terminal relies on escape sequence to represent those keys.
Add a Global Key to Activate Insert Mode
Normally, you switch to command mode, then press a key to activate insert mode. But you can add a dedicated key to activate insert mode if you have extra thumb keys on your keyboard. [see Ergonomic Keyboard Reviews]
;; make End key to activate insertion mode (global-set-key (kbd "<end>") 'xah-fly-insert-mode-activate)
Add Global Key to Toggle Command/Insert
;; make F4 toggle command/insert mode (global-set-key (kbd "<f4>") 'xah-fly-mode-toggle)
Add Key to Insert Mode to Activate Command Mode
If you don't want to add a global key such as F4 to activate command mode, because they are too far, and you don't have a batman keyboard with extra thumb keys, but you want to use some easy to reach key such as backslash to activate command mode while you are in insert mode, here's how.
This is useful when you want a single key to switch back to command mode while in insert mode.
(define-key xah-fly-insert-map (kbd "\\") 'xah-fly-command-mode-activate)
note: if you set \ to do something while in insert mode, you won't be able to insert a backslash by the key \. To insert a backslash, press Ctrl + q first.