#!/usr/bin/python3

import pyatspi

def listener(e):
    if not e.detail1:
        return

    try:
        action = e.source.queryAction()
    except:
        return

    for i in range(action.nActions):
        print(e.source, action.getName(i), action.getKeyBinding(i))

pyatspi.Registry.registerEventListener(listener, "object:state-changed:selected")
pyatspi.Registry.start()
