key
key()
Immediately returns an integer value corresponding to the currently pressed keyboard key. If no key has been pressed since the last call to the key function then the number zero (0) will be returned.
if key = 47 then print key
will not display the desired results, because it's calling key twice in succession, and will return different values each time. This code will do what you want:
a = key if a = 47 then print a
#press any keys loop: pause 1 a = key print a+" "+chr(a) goto loop