How to ssh from iPad with external keyboard and Emacs?

Prompt is generally considered to be the best (or at least among the best) SSH clients for iOS. I've never used it specifically for emacs (as I don't use emacs) but I've never seen it send strange extra characters, even when sending control characters to, say, nano.

Edit: Prompt version 1.3.2 now has a feature where you can use the Escape key as a Meta key.


I have also started using Emacs via SSH from my iPad with an external Bluetooth keyboard. I'm using Prompt and I've come up with the following code to "re-enable" the Option key as Meta. most of the keys work except for B, E, I, N, U and `. Put this in your .emacs file. Note that I use the Dvorak layout and I haven't tested this with a QWERTY layout.

(define-key key-translation-map [?\C-h] [?\C-?]) ; Unmask 'delete' as backspace

(let ((translations '( 229 [?\M-a]  nil [?\M-b]   231 [?\M-c]  8706 [?\M-d]   nil [?\M-e]
                       402 [?\M-f]  169 [?\M-g]   729 [?\M-h]   nil [?\M-i]  8710 [?\M-j]
                       730 [?\M-k]  172 [?\M-l]   181 [?\M-m]   nil [?\M-n]   248 [?\M-o]
                       960 [?\M-p]  339 [?\M-q]   174 [?\M-r]   223 [?\M-s]  8224 [?\M-t]
                       nil [?\M-u] 8730 [?\M-v]  8721 [?\M-w]  8776 [?\M-x]   165 [?\M-y]
                       937 [?\M-z]
                        96 [?\M-~]  161 [?\M-1]   162 [?\M-4]   163 [?\M-3]   167 [?\M-6]
                       170 [?\M-9]  171 [?\M-\\]  175 [?\M-<]   176 [?\M-*]   177 [?\M-+]
                       182 [?\M-7]  183 [?\M-\(]  186 [?\M-0]   187 [?\M-|]   191 [?\M-\?]
                       198 [?\M-\"] 230 [?\M-']   247 [?\M-/]   728 [?\M->]  8211 [?\M-\-]
                      8212 [?\M-_] 8216 [?\M-\]] 8217 [?\M-}]  8218 [?\M-\)] 8220 [?\M-\[] 
                      8221 [?\M-{] 8225 [?\M-&]  8226 [\?M-8]  8249 [?\M-#]  8250 [?\M-$] 
                      8260 [?\M-!] 8364 [\?M-@]  8482 [?\M-2]  8734 [\?M-5]  8800 [?\M-=]
                      8804 [?\M-,] 8805 [?\M-.] 64257 [?\M-%] 64258 [?\M-^])))
  (while translations
    (let ((key (car translations)) (def (cadr translations)))
      (if key
          (define-key key-translation-map (make-string 1 key) def)))
    (setq translations (cddr translations))))

This gets Prompt much closer to the Right Thing. It still needs to handle the missing keys (which trigger 'chords' that input multi-character sequences) or disable "non-ASCII" input altogether, and a "use Caps Lock as Control" setting would be very nice also. I'll email their customer support and see what they say.