(feat:keydown): listen cross platform events

This commit is contained in:
ManishMadan2882
2024-11-20 17:04:45 +05:30
parent e0a3b8004c
commit 48f47351ee
3 changed files with 68 additions and 6 deletions

View File

@@ -0,0 +1,27 @@
export const getOS = () => {
const platform = window.navigator.platform;
const userAgent = window.navigator.userAgent || window.navigator.vendor;
if (/Mac/i.test(platform)) {
return 'mac';
}
if (/Win/i.test(platform)) {
return 'win';
}
if (/Linux/i.test(platform) && !/Android/i.test(userAgent)) {
return 'linux';
}
if (/Android/i.test(userAgent)) {
return 'android';
}
if (/iPhone|iPad|iPod/i.test(userAgent)) {
return 'ios';
}
return 'other';
};