How can I check if the user has a cursor to hover on things, preferably using javacscript? (Using bootstrap too)
if (hasCursor()) {
doCode();
}
I tried just checking if it is a touch device, but my laptop is a 2-in-1, so I cant test it.
How can I check if the user has a cursor to hover on things, preferably using javacscript? (Using bootstrap too)
if (hasCursor()) {
doCode();
}
I tried just checking if it is a touch device, but my laptop is a 2-in-1, so I cant test it.
You are testing for the ability to hover, which is currently in practice synonymous with having a cursor, but might not be in future. So use the any-hover
query that tests whether the user has any method of hovering.
if(window.matchMedia("(any-hover: none)").matches) {
doCode();
}