What is Keyboard Focus in a Computer?
Keyboard focus refers to the ability of an user interface element to interpret input coming from the keyboard. That is, if an element has keyboard focus, and you press a key, it can do something about it. If it doesn't have keyboard focus, it can't do anything about it. Or least it shouldn't. Only one user interface element may have keyboard focus in a window, and only one window may be active at a time, which means that there is always only one element that can receive keyboard input at a time.
The simplest way to understand keyboard focus is to think of text boxes. You can only type on a text box if you click on it. When you click on it, what happens is that the text box gains keyboard focus. That is, after you click on the text box, the text boxes becomes the focused element. When you start typing in one text box, it interprets your key presses and text starts appearing inside of it. However, other text boxes on the screen which would normally also be able to do this will ignore everything you type. That's because the other boxes don't have keyboard focus. Only one box has it.
Controlling Keyboard Focus with the Keyboard
In general, it's possible to cycle which element has keyboard focus by pressing the Tab key, and to cycle in reverse order by pressing Shift-Tab.
Controlling Keyboard Focused Elements
When an element has keyboard focus, it's possible to control it without using the mouse, using only the keyboard. This is important for accessibility, so any accessible application provides this ability. What you can do and what keys you can press depends on the element.
On any element, you can open its context menu (which normally would open with a right click) by pressing the menu key on the keyboard, located between the right Ctrl and Winkey.
For textboxes, you can type in the textbox.
For buttons, pressing Enter or the Spacebar activates the button.
For checkboxes, radio buttons, and switches, pressing Enter or the Spacebar toggles it on and off.
For list boxes, combo boxes, and dropdown list buttons, the up and down arrow keys changes the selected item on the list. The Enter and Esc keys close dropdown lists.
For list panes, the arrow keys navigate the list, and the Enter key activates the item (which otherwise would require a double click).
For sliders, the left and right arrow keys controls a horizontal slider, while the up and down arrow keys control a vertical slider.
For menubars, menus, dropdown menus, and popup menus, the up and down arrow keys navigate the menu, and the right arrow key opens a submenu that opens to the right. The Enter key activates the menu. The Esc key closes the menu without activating anything.
Leave a Reply