<p>GNU/Linux text console, X11 not involved, indeed not even
installed. Keyboard is US layout, keymap US default. Kernel
version 2.20.x or later.</p>

<p>An application written in C is getting keyboard input in
translation mode, i.e. <code>XLATE</code> or <code>UNICODE</code>. When a key is
pressed, the application receives the corresponding
keystring. As an example, you press F1, the application
reads <code>"\033[[A"</code>.</p>

<p>Before the kernel sends the keystring to the application, it
must know which key is pressed, i.e. it must know its
scancode. In the F1 example above, the scancode for the key
pressed is 59 or 0x3b.</p>

<p>That's to say even when the keyboard is in translation mode,
the scancodes are held somewhere in memory. How can the
application access them without switching the keyboard to
<code>RAW</code> or <code>MEDIUMRAW</code> mode? A code snippet would help.</p>

Sure, the code you want to look at is in kbd-1.12.tar.bz2, which is the source bundle for the 'kbd' package. The 'kbd' package provides tools such as 'dumpkeys', 'showkeys' and 'loadkeys', which are useful for looking at the current keyboard mapping, checking what keys emit what scancodes, and loading a new mapping.
You will have to communicate with the kernel via ioctls, and it's quite complicated, so I recommend reading the source of that package to see how it's done.
Here's a link to the tarball:
kbd-1.12.tar.bz2 (618K)
.