Two solutions immediately come to mind:
1. create a widget and add a keypress handler (addDomHandler, this is
a protected method so you have to inherit an existing Widget subclass:
SimplePanel, AbsolutePanel, etc.); you should get events thanks to
bubbling, but not events directed to text boxes because they "eat"
them (stopPropagation)
2. preview events (Event.addNativePreviewHandler); here you'd get
events before they get to their target, including text boxes, so you'd
have to check that the actual target is not a text box.