How do I detect hardware keyboard presence with javascript?

后端 未结 5 1945
攒了一身酷
攒了一身酷 2020-12-17 10:30

What is the best cross-browser and cross-platform way to detect hardware keyboard presence with javascript?

5条回答
  •  既然无缘
    2020-12-17 11:09

    Could you try the theoretical opposite? Instead of trying to detect keyboard hardware, why not try to detect a touch screen? With the ontouchstart event;

    if ('ontouchstart' in document.documentElement) {
        // show icon
    }
    

提交回复
热议问题