Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (item && item.type === 'submenu') {
this.triggerActiveItem();
} else {
this.rootMenu._menuRequested.emit('next');
}
return;
}
// Down Arrow
if (kc === 40) {
this.activateNextItem();
return;
}
// Get the pressed key character.
let key = getKeyboardLayout().keyForKeydownEvent(event);
// Bail if the key is not valid.
if (!key) {
return;
}
// Search for the next best matching mnemonic item.
let start = this._activeIndex + 1;
let result = Private.findMnemonic(this._items, key, start);
// Handle the requested mnemonic based on the search results.
// If exactly one mnemonic is matched, that item is triggered.
// Otherwise, the next mnemonic is activated if available,
// followed by the auto mnemonic if available.
if (result.index !== -1 && !result.multiple) {
this.activeIndex = result.index;
let i = this._activeIndex;
let n = this._menus.length;
this.activeIndex = i === 0 ? n - 1 : i - 1;
return;
}
// Right Arrow
if (kc === 39) {
let i = this._activeIndex;
let n = this._menus.length;
this.activeIndex = i === n - 1 ? 0 : i + 1;
return;
}
// Get the pressed key character.
let key = getKeyboardLayout().keyForKeydownEvent(event);
// Bail if the key is not valid.
if (!key) {
return;
}
// Search for the next best matching mnemonic item.
let start = this._activeIndex + 1;
let result = Private.findMnemonic(this._menus, key, start);
// Handle the requested mnemonic based on the search results.
// If exactly one mnemonic is matched, that menu is opened.
// Otherwise, the next mnemonic is activated if available,
// followed by the auto mnemonic if available.
if (result.index !== -1 && !result.multiple) {
this.activeIndex = result.index;
function keystrokeForKeydownEvent(event: KeyboardEvent): string {
let key = getKeyboardLayout().keyForKeydownEvent(event);
if (!key) {
return '';
}
let mods = '';
if (event.ctrlKey) {
mods += 'Ctrl ';
}
if (event.altKey) {
mods += 'Alt ';
}
if (event.shiftKey) {
mods += 'Shift ';
}
if (event.metaKey && Platform.IS_MAC) {
mods += 'Cmd ';
}
onKeyDown(grid: DataGrid, event: KeyboardEvent): void {
switch (getKeyboardLayout().keyForKeydownEvent(event)) {
case 'ArrowLeft':
this.onArrowLeft(grid, event);
break;
case 'ArrowRight':
this.onArrowRight(grid, event);
break;
case 'ArrowUp':
this.onArrowUp(grid, event);
break;
case 'ArrowDown':
this.onArrowDown(grid, event);
break;
case 'PageUp':
this.onPageUp(grid, event);
break;
case 'PageDown':