Here you go then, this does as Benjamin suggested, using a DLL to convert the scancode to a key string entry, you should be able to change this to do what you want.
load dll "user32.dll", 1
do
cls
Text 10,10,STR$(Scancode())
Text 50,10,GetKeyName(scancode())
loop
function GetKeyName(ScanCodeValue)
name$ = space$(64)
If Not Call DLL(1, "GetKeyNameTextA", ScanCodeValue << 16, name$, 64) then name$ = str$(ScanCodeValue)
endfunction name$
EDIT: This reverses it like you want
load dll "user32.dll", 1
dim KeyCodes(255) as string
Init()
do
cls
If KeyState(GetKeyCode("F1")) = 1 Then End
loop
function GetKeyName(sCode as integer)
name$ = KeyCodes(i)
endfunction name$
function Init()
for i = 0 to 255
KeyCodes(i) = space$(64)
if not call dll(1, "GetKeyNameTextA", i << 16, KeyCodes(i), 64) then KeyCodes(i) = "<<scancode " + str$(i) + ">>"
next i
endfunction
function GetKeyCode(name as string)
for i = 0 to 255
if KeyCodes(i) = name then exitfunction i
next i
endfunction 0