1. cdk 文档 https://material.angular.io/cdk/categories
2. keycodes 模块提供
-
import { hasModifierKey } from "@angular/cdk/keycodes";
(1)判断是否有 "修饰按键" 按下(type ModifierKey = 'altKey' | 'shiftKey' | 'ctrlKey' | 'metaKey';)
-
it('should check whether the alt key is pressed', () => { const event = createKeyboardEvent('keydown', 0); const altEvent = createKeyboardEvent('keydown', 0, '', {alt: true}); expect(hasModifierKey(event)).toBe(false); expect(hasModifierKey(altEvent)).toBe(true); });
(2)https://github.com/angular/components/blob/master/src/cdk/keycodes/keycodes.ts