Read

My home, end and delete keys were not working in my unix terminal (xterm) or in my Matlab console. For instance in the Matlab console (Matlab run in –nodesktop mode), all I was getting after pressing the home or end key was 4~ or 5~, same was going on for the terminal (xterm and csh). As most shells recognize the ctrl+a, ctrl+e, ctr+d shortcuts for home (beginning of line), end (end of line) and delete and as Matlab too recognizes these shortcuts, the simplest solution is to have your keys sending these shortcuts when in a terminal. You probably do not want to completely reconfigure your keys as they might be working fine in text editors.

“string(0x01)” means to send the code 0x01 which is the ASCII code for ctrl+a. “string(0x02)” would mean ctrl+b, “string(0x05)” indeed means ctrl+e etc.
A list of ASCII control code can be found here : http://www.phanderson.com/C/ascii.html
(Btw, If someone can explain me why the fist ASCII code is ctrl+a and not simply a I would be impressed).

How to test the configuration
To load the .Xdefaults file enter:

xrdb -merge ~/.Xdefaults

To check the state of your X configuration:

xrdb -query

To test your configuration, it is also often useful to check which code a key sends. To do this, in a terminal, just press ctrl+v then press the key. The code sent by the key should appear, for instance ^a (=ctrl+a) if you pressed the home key or directly ctrl+a.
[Edit]
Also it is important that you know which terminal and shell you are using. To know this:

echo $SHELL
echo $TERM

Bonus
As a bonus here are a few more configurations:
To be able to use page up, page down to scroll in xterm:

Notice that 0x0d is nothing else than the ASCII code of carriage return.

To get autocompletion thanks to your history in the command line. That is you press a few characters then you press up and it will complete the line with the last command with the same beginning in your history. With this, it is useful to have a long history and the same history file for all your opened terminals.
If you use tcsh, put this in your ~/.cshrc file:

# 5000 last commands are saved
set history = 5000
# All terminals merge their history in one file
set savehist=(5000 merge)
if ( $?tcsh ) then
bindkey -k up history-search-backward
bindkey -k down history-search-forward
# inser to backward-delete-word
bindkey ^[[2~ backward-delete-word
# Prompt with the current path
set prompt="%~>"
endi

\e means escape key. Escape key also sometimes appear as ^[. So if you press ctrl+v then up arrow you will get ^[[A.

Notice that once you have correctly set up the home, end keys and the up, down keys for history you will have the same configuration between xterm and Matlab.

All this should pretty much work under UNIX or LINUX. However, with all the configurations around (Linux,Unix,HP-UX,Unix through exceed/csh tcsh/gnome,KDE,CDE,etc.) a few things might not work in your configuration. So good luck!