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