All keys on any possible keyboard have an ID, which is a number between 0 and 511. In practice, most, if not all keyboards can only generate key codes from 0 to 127.

If you know the key code, but don’t have that key on your keyboard, such as some keys on extended keyboards, or the extra key on an ISO keyboard, then you can still set the output for that key.

You can choose “Edit Key…” from the Keyboard menu, and it will ask you how to specify the key you want to edit. You can either press the key on the keyboard or click the key on the on-screen keyboard, or enter the key code. Whichever you choose, you will get a dialog allowing you to supply the new output.