A minor improvement to this discussion: here's a working script formatted correctly that can be copy/pasted into a power table's initialize function, ready-to-go. I think a broader usage is also more clearly demonstrated by using an example with the CTRL key:
# PowerTable initialize function
# Adds a hotkey action bound to the keystroke "CTRL+D"
from javax.swing import AbstractAction, JComponent, KeyStroke
class MyAction(AbstractAction):
def actionPerformed(self, event):
print 'Success'
a = MyAction()
k = KeyStroke.getKeyStroke("control D")
self.registerKeyboardAction(a, k, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
Edit: this is also relevant for people wanting to add hotkeys to a table with editable cells: