How to check which key i have pressed?

i want to check which key i have pressed. So inside Debug.Log()… what should i write? If i am pressing K … K should come in the console window.

if(Input.anyKey)
{
Debug.Log(Input.inputString);
}

void Update()
{
if (Input.GetKeyUp(“k”))
{
Debug.Log(“K was pressed”);
}
}

In certain cases you might want to use the following:

void OnGUI() {
   Event e = Event.current;
   if (e.isKey)
      Debug.Log("e.keyCode: "+e.keyCode);
}

I was trying to understand the button output of a peripheral recognized as a keyboard (wireless presenter), and Input.inputString didn’t help me because it was returning an empty string for non printable characters such as PageUp.