The use of navigator.userAgent is not advised as per MDN. In my application I want to have a shortcut for del key.
In mac del key (is backspace) with charCode = 8. In windows del key charCode = 46.
I want to treat both keyEvents same. I am currently using userAgent but it is unreliable as that property can be spoofed. I am wondering what is the best way to know the client OS otherwise.
More deprecated navigator properties navigator.appVersion navigator.platform
/* code objective */
if ((keycode == 8 && os == 'macintosh') || keycode == 46) {
//This is keyboard shortcut to perform delete
}