Calling GetButtonDown on an input axis

Hi, this is (in pseudocode) the behaviour I want to create:

if (Input.getButtonDown( someAxis.positiveButton )) //do smoething
if (Input.getButtonDown( someAxis.negativeButton )) //do smoething else

I found on another thread following solution:

 if (Input.GetButtonDown("someAxis") && Input.GetAxisRaw("someAxis") > 0) //do something
 if (Input.GetButtonDown("someAxis") && Input.GetAxisRaw("someAxis") < 0) //do something else

But this doesn’t work for following case:
Let’s say I keep “A” pressed cosntantly and while keeping A pressed I press D every now end then.
I want to know every time that D is pressed even if A is pressed at the same time, but GetAxisRaw will only go to 0, so the corresponding function won’t trigger.

How do I trigger an action every time the positive or negative Key of an Axis are pressed?

I had the idea of checking the raw axis value of the previous frame.
So this is the monstruousity of an answer I’ve come up with:

if(Input.GetButtonDown("Horizontal")) {
			if(Input.GetAxisRaw("Horizontal") > 0) print("D pressed");
			else if(Input.GetAxisRaw("Horizontal") < 0) print("A pressed");
			else if(prev < 0) print("D pressed");
			else if(prev > 0) print("A pressed");
		prev = Input.GetAxisRaw("Horizontal");

Im sure there are more elegant and efficient ways of doing it, but it does work at least.