JSキーボードのキーキャプチャctrlKeyとshiftKey

JSキーボードのキーキャプチャ

背景: プロジェクトに取り組む過程で、Ctrl キーを押しながら複数の項目を選択するだけでなく单击和双击事件、頻繁に使用されます。Ctrl键
1. CtrlキーctrlKey
 function doKeyDown()
    {
    
    
        if (event.ctrlKey)
        {
    
    
          alert("You pressed the Ctrl")
        }
    }
2. Ctrlキー+Enterキー
 function doKeyDown()
    {
    
    
        if (event.ctrlKey && event.keyCode == 13)
        {
    
    
          alert("You pressed the Ctrl + Enter")
        }
    }
3. シフトキーshiftKey
 function doKeyDown()
    {
    
    
        if (event.shiftKey)
        {
    
    
          alert("You pressed the Shift")
        }
    }

おすすめ

転載: blog.csdn.net/sunshineTing2/article/details/129427320
おすすめ