This command implements simple pointer and keyboard grabs for Tk. Tk's grabs are different than the grabs described in the Xlib documentation. When a grab is set for a partic- ular window, Tk restricts all pointer events to the grab window and its descendants in Tk's window hierarchy. When- ever the pointer is within the grab window's subtree, the pointer will behave exactly the same as if there had been no grab at all and all events will be reported in the normal fashion. When the pointer is outside window 's tree, button presses and releases and mouse motion events are reported to window , and window entry and window exit events are ignored.
Grabs are local by default.
During global grabs the window manager will not receive pointer events either. Tk grabs the keyboard so that all keyboard events are always sent to the grabbing application. The focus command is still used to determine which window in the application receives the keyboard events. The keyboard grab is released when the grab is released. Grabs apply to particular displays.