Detecting mobile devices

Hi all ... Quite often I need to know (or at least have a decent stab at knowing) whether a mobile/small screen device is being used on a survey. I know traditionally we use screenwidth with a cut off of 800px. But phone displays are more pixel dense these days so it really doesn't work. My phone, as an example, is a Samsung Galaxy S21FE and comes up as 980px width so my code doesn't flag it as small screen. I DO notice on my phone that the mobile-centric layout comes into play. So it IS picking up somewhere in the background that it's a phone. Has anyone managed to more reliably pick this up (in surveys)?

1 reply