【angular2】@angular/cdk/keycodes 学习02

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

 

--------小尾巴 ________一个人欣赏-最后一朵颜色的消逝-忠诚于我的是·一颗叫做野的心.决不受人奴役.怒火中生的那一刻·终将结束...
原文地址:https://www.cnblogs.com/tianxiaxuange/p/14415487.html