MCPcopy Create free account
hub / github.com/angular/components / _handleKeydown

Method _handleKeydown

src/material/menu/menu.ts:364–393  ·  view source on GitHub ↗

Handle a keyboard event from the menu, delegating to the appropriate action.

(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

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.

Callers 1

_createOverlayFunction · 0.45

Calls 3

hasModifierKeyFunction · 0.90
setFocusOriginMethod · 0.80
onKeydownMethod · 0.65

Tested by

no test coverage detected