【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

 

posted @ 2021-02-19 12:03  耶梦加德  阅读(58)  评论(0编辑  收藏  举报