-
Notifications
You must be signed in to change notification settings - Fork 0
Home
A JavaScript library that detects the client device's capabilities for support of several sensors like touch, motion and orientation sensors and also provides out of the box support for browser detection and OS/Platform detection.
Device capabilites.js is a pure JavaScript library loosely based on the device module in Photonstrom's Phaser framework. The library is quick and simple to use. It can identify if the device is a desktop or mobile, detect the platform the device is running on and find out the name of the browser the library is running on.
- Browser detection
- Platform detection
- Device detection
- Feature detection
Note: Other than "Feature detection" all other detections are based on the browser's User Agent String
Device capabilities.js library is able to detect and differentiate between Desktop and Mobile (Tablets are also detected as mobiles)
The library can detect the name of the current browser.
Identifiable browsers are:
Desktop
- Chrome
- Firefox
- Internet Explorer
- Edge
- Opera
- Safari
Mobile Devices
- Chrome for Android and iOS.
- Firefox for mobile.
- IE Mobile.
- Edge Mobile.
- Android Native browser.
- Silk browser for Kindle.
The library is also able to detect the platform or operating system on which device is running.
Detectable Platforms are:
- Windows
- Linux
- Mac OS
- Windows Phone
- Android
- iOS
- WebOS
- Kindle
- Blackberry
- Firefox OS
The library has the ability to detect the following api features supported by the browser and the device.
- HTML5 Local storage API
- HTML5 Canvas API
- Touch sensor API
- Game pad API
First, Download the device-capabilites.js library and include it in the html file
<script src="path/to/device-capabilities.js"></script>
Then instantiate the deviceCapabilities class and use its properties for examining the device's capabilities.
Example:
/* create an instace of the deviceCapabilites class*/
var devAbility = new Device.deviceCapabilities();
// Find out if the device is a desktop
if(devAbility.desktop){
console.log("The device is a desktop");
}
// Check if the browser is chrome on a mobile device
if(devAbility.Browser.chromeMobile){
console.log("The browser is chrome for mobile");
}
// Know if device supports touch
if(devAbility.Sensors.touch){
console.log("The device supports touch interface");
}
author: https://svijaykoushik.github.io/
twitter: @VijaykoushikS
issues: https://github.com/svijaykoushik/device-capabilities.js/issues
email: svijaykoushik@hotmail.com