Everything is up to you.
what kind of data type is a scancode?
All you will get from the hardware is a byte value that represents the scancode.
how does the keyboard's user buffer get cleared?
There are two buffers: The firs obn eis in hardware on the keyboard controller. It collects all scancodes. Everytime you read from port 0x60 the buffer decreases. If it is empty you get 0x00 as scancode which actually is no scancode.
On the other hand there can be a buffer in your OS. Consider of a program which wants to read a string. Then your OS needs a buffer where it collects every "arriving" scancode (better to say its corresponding ASCII-Value). Normally the sign that input is finished is that the user presses ENTER. If your keyboard driver sees this scancode it gives control back to the user program (and copying the buffer to the user program).
And if the program is again requesing for user input, the keyboard driver starts over again. So there is no need to clear the buffer. It is simply overwritten when waiting for the next input.
But... I don't get hex code when i using k_printf (only something indefinite text).
I think you did a mistake when calling k_printf. I think this function can only print strings. But the scancode is no string. It's a number. You have to convert it to a string and then to print it.
k_printf has a pointer to a string as parameter. And you uses the scancode as this pointer. It just points somewhere in memory. This is why you get these strange characters.