Easy way:
If you have a frequent check on keyboard, then it should be placed there.
A little more difficault (If not such a frequent check):
Use an interrupt of 100msec or faster and add a check for key A in there.
If Key A is pressed, and just have to set some pins, it's ok to call the required function from within interrupt.
If the job to be done on A pressed is time consuming, then you should mark a bit flag and when you reach your idle loop, execute the function (and reet this bit flag).
The 100% correct approatch:
you should use a task loop (like RTOS) and add a task to periodically check the keyboard and act.
This design, probably require the modification of your code developing technique...