Hi!
I'm not familiar with the inner workings of this library, but I think I can partially answer your question
.
this is using object oriented programming, which can be counterintutive if you're not familar with it -- as you've discovered!
'tcod' is an "object". With object-oriented programming, you can create 'objects' which maintain a state (that is, store the value of several variables internally), and also have their own methods which act on them.
Thus, 'console_wait_for_keypress' and 'console_is_key_pressed' are functions belonging to, and acting on, the tcod object.
What I suspect is happening here is that the 'console_wait_for_keypress' is waiting for a keypress and then storing it's value internally within the tcod object. It also passes the key as a return value, but this is just 'extra'.
The 'console_is_key_pressed' functions are then probably checking against this internal value. So, the intial function was neccesary (to wait for the keypress, and to store the value internally), even though the 'key' variable isn't used.
'KEY_KP8', and such, are constants stored within the tcod object, those fucntions are comparing the internally stored key-value against the various constant values.
Hope this helped a little bit? It's hardly a comprehensive introduction to OOP, but hopefully it removes at least a bit of the WTF.