* Handles a keyboard event on the tree. * @param event Keyboard event that represents the user interaction with the tree.
(event: KeyboardEvent)
| 142 | * @param event Keyboard event that represents the user interaction with the tree. |
| 143 | */ |
| 144 | onKeydown(event: KeyboardEvent) { |
| 145 | const key = event.key; |
| 146 | |
| 147 | switch (key) { |
| 148 | case 'Tab': |
| 149 | // Return early here, in order to allow Tab to actually tab out of the tree |
| 150 | return; |
| 151 | |
| 152 | case 'ArrowDown': |
| 153 | this._focusNextItem(); |
| 154 | break; |
| 155 | |
| 156 | case 'ArrowUp': |
| 157 | this._focusPreviousItem(); |
| 158 | break; |
| 159 | |
| 160 | case 'ArrowRight': |
| 161 | this._horizontalOrientation === 'rtl' |
| 162 | ? this._collapseCurrentItem() |
| 163 | : this._expandCurrentItem(); |
| 164 | break; |
| 165 | |
| 166 | case 'ArrowLeft': |
| 167 | this._horizontalOrientation === 'rtl' |
| 168 | ? this._expandCurrentItem() |
| 169 | : this._collapseCurrentItem(); |
| 170 | break; |
| 171 | |
| 172 | case 'Home': |
| 173 | this._focusFirstItem(); |
| 174 | break; |
| 175 | |
| 176 | case 'End': |
| 177 | this._focusLastItem(); |
| 178 | break; |
| 179 | |
| 180 | case 'Enter': |
| 181 | case ' ': |
| 182 | this._activateCurrentItem(); |
| 183 | break; |
| 184 | |
| 185 | default: |
| 186 | if (event.key === '*') { |
| 187 | this._expandAllItemsAtCurrentItemLevel(); |
| 188 | break; |
| 189 | } |
| 190 | |
| 191 | this._typeahead?.handleKey(event); |
| 192 | // Return here, in order to avoid preventing the default action of non-navigational |
| 193 | // keys or resetting the buffer of pressed letters. |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | // Reset the typeahead since the user has used a navigational key. |
| 198 | this._typeahead?.reset(); |
| 199 | event.preventDefault(); |
| 200 | } |
| 201 |
nothing calls this directly
no test coverage detected