Combobox in a container example

Structure

<div class="labels"">
  <label id="cbolbl" for="comboex">Job Category</label>
</div>

<div role="application">
  <div role="combobox" aria-expanded="false" aria-labelledby="cbolbl" aria-activedescendant="l1" id="cbocontainer">
    <div role="presentation">
      <input type="text" id="comboex" aria-owns="listchoices" size="50" readonly="readonly" value="Any">
      <img role="button" src="drop.jpg" alt="" id="comboexbtn" class="dropdown">
    </div>

    <ul class="ckrbList" id="listchoices" role="listbox" aria-multiselectable="true" aria-labelledby="cbolbl" style="display: none">
      <li role="option" aria-selected="false" aria-checked="false" tabindex="0" id="l1" aria-setsize="5" aria-posinset="1">
        <img src="unchecked.gif" alt="">
        Actuarial
      </li>
      <li role="option" aria-selected="false" aria-checked="false" tabindex="-1" id="l2" aria-setsize="5" aria-posinset="2">
        <img src="unchecked.gif" alt="">
        Administrative/Office/Clerical
      </li>
      <li role="option" aria-selected="false" aria-checked="false" tabindex="-1" id="l3" aria-setsize="5" aria-posinset="3">
        <img src="unchecked.gif" alt="">
        Audit/Compliance/Legal
      </li>
      <li role="option" aria-selected="false" aria-checked="false" tabindex="-1" id="l4" aria-setsize="5" aria-posinset="4">
        <img src="unchecked.gif" alt="">
        Call center/Sales and service
      </li>
      <li role="option" aria-selected="false" aria-checked="false" tabindex="-1" id="l5" aria-setsize="5" aria-posinset="5">
        <img src="unchecked.gif" alt="">
        Training Programs/Internship
      </li>
    </ul>
  </div>
</div>

Keyboard usage

The following keystrokes are used in this combobox example.

Combobox keystrokes
Element Keystroke Action
Edit field ENTER or SPACE Opens the dropdown list if it's currently closed; otherwise, opens the dropdown list.
Edit field ESC Closes the dropdown list if it is already opened.
Edit field TAB and SHIFT + TAB Closes the dropdown list if it is already open, and moves focus to the next and previous interface elements respectively.
Edit field DOWN CURSOR or UP CURSOR Moves focus to the listbox, opening the list if it's not already open.
Option SPACE Toggles the currently focused item's aria-checked state between true and false.
Option ENTER Toggles the currently focused item's aria-checked state between true and false, and then closes the dropdown list.
Option ESC Closes the dropdown list if it is already opened.
Option TAB and SHIFT + TAB Closes the dropdown list if it is already open, and moves focus to the next and previous interface elements respectively.
Option DOWN CURSOR or UP CURSOR Moves focus to the next or previous item in the listbox, respectively. The behavior is cyclic around the dropdown items.

Back to WAI-ARIA examples.