I have to log into a VAX and the program I use on it expect that keys F1-F20 will be available.
Terminal.app does not help me here. Nominally the F1-F20 keys run along the top of my Apple wireless keyboard. Unfortunately two things coincide to get in the way of VAXy goodness,
Firstly, F14-F20 are allocated as keys for the likes of screen brightness, sound volume and CD/DVD eject. Thus, whatever modifiers are used the result gets nowhere near Terminal.app.
Secondly, Terminal.app is a little braindead. For some reason F1-F4 are assigned to P, Q, R and S. This I discovered thanks to this handy little snippet of python from NPC :
#!/usr/bin/python
import curses
import curses.ascii
def mainloop(scr):
while 1:
scr.keypad(1)
ch = scr.getch()
try:
scr.erase()
scr.addstr(0,0, “%s, %s, %s” %
(curses.keyname(ch), curses.ascii.unctrl(ch), ch))
except:
pass
scr.refresh()
if __name__ == “__main__”:
curses.wrapper(mainloop)
Also, option-F1 to F16 and shift-F1 to F12 are assigned to a bizarre combination of other F-key values. I’m sure there is a reason, I just can’t see it.
Anyway, I want the keys assigned as they are on our PCs - so that I can use F1-F12 as F9-F20. Being able to send F1-F4 would be nice too. So the solution is to edit the Keyboard section in the Window Settings of Terminal. This is a bit fiddly as you have to use their delete button rather than press delete - as pressing the key sends the value of delete to the window. The result is this:
F1 -> \O33[11~
F2 -> \O33[12~
F3 -> \O33[13~
F4 -> \O33[14~
F15-F20 -> Leave as default
option-F1 -> \O33[20~
option-F2 -> \O33[21~
option-F3 -> \O33[23~
option-F4 -> \O33[24~
option-F5 -> \O33[25~
option-F6 -> \O33[26~
option-F7 -> \O33[28~
option-F8 -> \O33[29~
option-F9 -> \O33[31~
option-F10 -> \O33[32~
option-F11 -> \O33[33~
option-F12 -> \O33[34~
And lo, the Function keys were passed correctly to the terminal (at least as far as curses and the VAX is concerned)