How to detect pressed keys on the click of AngularJS

后端 未结 5 1576
渐次进展
渐次进展 2021-02-07 00:44

I\'m using angularjs on a web application that I need to figure out how can I detect is keys like ctrl, shift or alt are pressed when I click so

5条回答
  •  北荒
    北荒 (楼主)
    2021-02-07 01:30

    If you are trying to capture a key combination, such as Ctrl-Enter, you can look at the window object

    For example to find Ctrl-Enter use

    if(window.event.keyCode == 13 && window.event.ctrlKey == true)
    

提交回复
热议问题