/dev tips

(105) A mobile optimised version of DevTools Use the Application Panel to view various web metadata (107)

Chrome DevTools: Use the Sensors Pane to control specific device sensors

14 Jun 2016
Use the Sensors Pane to control specific device sensors

DevTools has received some updated UI and controls for device sensors.

You can control geolocation by specifying a latitude/longitude, or even using some presets such as London or Tokyo. You can use this piece of JavaScript to retrieve geolocation information:

navigator.geolocation.getCurrentPosition(pos => console.log(pos.coords));

You can also control device orientation (alpha, beta, gamma) with some included presets like portrait, landscape, 'display down' and others. You can use this piece of JavaScript code to observe for orientation changes:

window.addEventListener("deviceorientation", evt => console.log(evt), true);

Finally, there is also a control for device-based or force enabled touch.

Sign up to receive a developer tip, in the form of a gif, in your inbox each week.