MCPcopy Index your code
hub / github.com/angular/components / _handleKeydown

Method _handleKeydown

src/material/menu/menu.ts:362–391  ·  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

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.

Callers 1

_createOverlayFunction · 0.45

Calls 3

hasModifierKeyFunction · 0.90
setFocusOriginMethod · 0.80
onKeydownMethod · 0.65

Tested by

no test coverage detected