One method is to send escape + the character. So hitting ALT+J will send an
escape character followed by 'J'.
Alternatively, your terminal might simply read the character value in and set
it's most significant bit high before sending that byte to the terminal. What
does does that mean?
Let's say you were to hit ALT+J this time. J, in ascii is 74 in ascii. This
number represented in binary is: 01101010. Having alt held down
sets the left-most (most significant) bit high, becoming
11101010.
Many terminals allow you to set which method of input it uses. XTerm, for instance, allows you through the menu accessed by control+leftclicking on the terminal (anywhere). Select "Meta sends Escape" and alt-key combinations will send escape+character. If "Meta sends Escape" is unchecked, then your terminal will set-high the most significant bit before sending the character.
Here's a perl oneliner that'll let you see what's going on. The output for mat
is: char / ascii / binary where ascii is the hexadecimal value
of what you entered, and binary is the binary representation. You'll notice
that if "Meta sends Escape" is unchecked, then your terminal will set-high the
most significant bit before sending the character.
#!/usr/bin/perl
system("stty raw -echo");
while (sysread(STDIN,$foo,1)) {
printf("%s / %2x - ", ($foo =~ /[[:print:]]/ ? $foo : " "), ord($foo));
print unpack("B32", pack("n", ord($foo))) . "\r\n"
}