how can i store which button was pressed last time among many...

can i store button pin number and its state also....? if yes then HOW....?