Use the xev command. When you hit enter, xev will launch. xev takes all of your input and poops info about the key into the command line. I recommend bringing your mouse over the exit key of the xev window, hitting caps lock (or whatever key you want to find out about), and immediately exiting xev. The relevant lines on my system, for caps lock look something like:

You could also, now, get data for another key -- one you don't really use, and which, in the context you want to use the caps lock button in, doesn't do anything. So, if you want caps lock to activate the Unity searchbox (like super usually does), maybe use `, for example. On my machine:

keycode 49 (keysym 0x60, grave)

Bind the new key's function to the Caps Lock button, using xmodmap. I'm pretty sure you want to use a command like:

xmodmap -e "keycode 66=0x60"

Now, if you hit the physical caps lock button in a text box, the grave character (`) will appear. But if you map a shortcut key to it, it will do something else. If you want to be able to use it in a text box, perhaps replace caps lock with left shift, or f10, or something else that doesn't seem like it will interfere with the command you want to use.

Test it to make sure the command I gave you works the way you want it to.

Go to startup applications, and add that command to your startup applications. This way, the key will switch properly every time you start up.

You can also modify the behavior of Caps Lock using an XKBOption. These changes are even propogated to the virtual consoles (/dev/tty[1-6], or Ctrl-Alt-F[1-6]).

For instance, to disable Caps Lock, you would have the following in /etc/default/keyboard:

# Check /usr/share/doc/keyboard-configuration/README.Debian for
# documentation on what to do after having modified this file.
# The following variables describe your keyboard and can have the same
# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options
# in /etc/X11/xorg.conf.
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="caps:none"
# If you don't want to use the XKB layout on the console, you can
# specify an alternative keymap. Make sure it will be accessible
# before /usr is mounted.
# KMAP=/etc/console-setup/defkeymap.kmap.gz

Then you would run:

sudo dpkg-reconfigure keyboard-configuration

For a full list of the customizations of XKBOPTIONS, take a look at /usr/share/X11/xkb/rules/base.lst. Here's the full list from my Ubuntu 13.10 machine: http://sprunge.us/cUZO

The most robust solution is to buy a keyboard that lets you remap keys in firmware, i.e. a professional, programmable keyboard.

These usually cost around 200 bucks and also have high grade mechanical keyswitches. They are expensive, but they are the only way to avoid having to fight with this at every new machine you sit down at, and each time the developers make breaking changes to OS infrastructure as fundamental as the keyboard map.