![](/img/trans.png)
[英]How to Distinguish touchpad, touchscreen, or mouse which was touching by user, using JavaScript
[英]how can a webpage determine if a user has mouse or touchscreen input?
如果我有一個用html5和javascript編碼的網頁,它將如何檢測用戶擁有哪種輸入硬件? 給他們有用和正確的指示。 用戶可能擁有鼠標,觸摸屏,全部或全部鍵盤,智能手機上的受限鍵盤...等。
我不確定時會用它來避免鼠標懸停的影響。
<script>
var hasMouse = false;
window.document.addEventListener('mouseover', mouseFound);
function mouseFound() {
hasMouse = true;
window.document.removeEventListener('mouseover', mouseFound);
console.log('found a mouse');
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.