If you look at the Terminal->Preferences->Settings->Keyboard pane it displays how some keyboard keys and combinations map to shell strings.
The list seems really strange to me as it's missing a lot of combinations like Shift+F1 and it maps option+F1 and F6 to the same code. Also the codes shown look like ANSI escape sequences but the function key numbers (ones I checked) don't match up.
I'd like to find an explanation for these details and a reference for adding proper codes for missing combinations like Shift+F1. Thanks for your input