Detect if user is on touch screen

Engineer working in Cerebras. Latest work is Cerebras Inference. I love writing code in React, TypeScript, C++, Python. I spend most of my work hours tinkering with code.
Sometimes, it is useful to check if the user is on a touch screen. An example would be NOT to focus the textarea in touch screen. This is because the keyboard does not appear when user taps on the textarea.
Some code to detect touchscreen is shown below
const isTouchScreen =
'ontouchstart' in window ||
navigator.maxTouchPoints > 0 ||
// For Internet Explorer
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(navigator as any).msMaxTouchPoints > 0
PS: Code snippets for using them in the future.
