Isn't there a key-mapping utility? There is in most terminal emulators. The program probably uses one file for each type of connection.