Learn about XUL, a subset of XML used to describe user interfaces, that helps you to make rich user interfaces with nothing more complicated than a text editor. In the fifth part of this series you will receive an introduction to XPCOM, the object model used by XUL, and take a close look at a basic example of the combination of Mozilla components and interfaces that make up the abstraction layer.
One final thing you can use in the example is the keyset element. The keyset element is used to specify a key combination that someone using the application can press to select menuitems without having to navigate the menus. The keyset element contains its children, individual key elements that define the keyboard shortcuts. The key elements need an id attribute which ties in with an attribute used on the menuitem they are a shortcut for, a modifiers attribute which specifies which special key should be pressed, a key attribute which specifies the keyboard key used in conjunction with the special key, and an event that calls whichever function they should be associated with. For this example, you can use the following keyset:
You’ll need to associate each of the keys to their respective menuitems, so add a key="openKey" attribute to the open menuitem, a key="saveKey" attribute to the save menuitem and a key="exitKey" attribute to the exit menuitem. Now save the file and access it again via Mozilla, and press Ctrl + o to bring up the open dialog. If you expand the menu yourself, you’ll see that Mozilla has added explanatory text to the relevant menuitems to advise of the keyboard shortcuts that can be used.