Handle a keyboard event from the menu, delegating to the appropriate action.
(event: KeyboardEvent)
| 360 | |
| 361 | /** Handle a keyboard event from the menu, delegating to the appropriate action. */ |
| 362 | _handleKeydown(event: KeyboardEvent) { |
| 363 | const keyCode = event.keyCode; |
| 364 | const manager = this._keyManager; |
| 365 | |
| 366 | switch (keyCode) { |
| 367 | case ESCAPE: |
| 368 | if (!hasModifierKey(event)) { |
| 369 | event.preventDefault(); |
| 370 | this.closed.emit('keydown'); |
| 371 | } |
| 372 | break; |
| 373 | case LEFT_ARROW: |
| 374 | if (this.parentMenu && this.direction === 'ltr') { |
| 375 | this.closed.emit('keydown'); |
| 376 | } |
| 377 | break; |
| 378 | case RIGHT_ARROW: |
| 379 | if (this.parentMenu && this.direction === 'rtl') { |
| 380 | this.closed.emit('keydown'); |
| 381 | } |
| 382 | break; |
| 383 | default: |
| 384 | if (keyCode === UP_ARROW || keyCode === DOWN_ARROW) { |
| 385 | manager.setFocusOrigin('keyboard'); |
| 386 | } |
| 387 | |
| 388 | manager.onKeydown(event); |
| 389 | return; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * Focus the first item in the menu. |
no test coverage detected