Differentiating iPhones and iPads on Desktop View

I was wondering if there was another way for the browser to detect if the device is an iPhone or an iPad. When the user switches to desktop mode, the user agent string reports the device as a macOS Catalina. I have found a way to detect if the device is a mobile device but I can't find out if it is an iPhone or an iPad, and since we show different web components based on the device, this information becomes important.


I tried looking at javascript 'screen.width' property which gives the UIKit Size of the screen. This would have been a hack to identify the devices until the previous generation of devices, but the resolution of the iPhone 11 Pro exceeds that of one of the older iPads. Are there any other suggestions on detecting the devices that can be done with the browser on desktop view?