Differentiate between mouse and keyboard triggering onclick

前端 未结 7 1102
你的背包
你的背包 2020-12-03 13:09

I need to find a way to determine if a link has been activated via a mouse click or a keypress.



        
7条回答
  •  时光说笑
    2020-12-03 13:50

    You can use event.detail

    if(event.detail === 0) {
        // keypress
    } else {
        // mouse event
    }
    

提交回复
热议问题