This module has a number of methods related to tab navigation.

It can be used for widgets like dialogs, to control where the initial focus goes, and how to loop around (tabbing from the last field back to the first field, or shift-tabbing from the first field to the last field).