Detect touch devices in JavaScript

Today I’m writing about a JavaScript snippet that I use to detect if the device has a touchscreen.

This code won’t work on some old version of Chrome on Windows 8/8.1 because at this time the browser was supporting some touch features on non-touch devices. You can read about it here : http://www.stucox.com/blog/you-cant-detect-a-touchscreen/

You have to be aware that it is very difficult to detect if a device has a touchscreen because depending of the browser and operating system, the touch features can be implemented on a non-touch device. So I tested my snippet with Safari on iOS, Firefox, Chrome and Internet Explorer 10/11 on Windows 8.1 and Windows 10 technical preview but I can’t tell for how long it will keep working.

You can test this snippet thanks to this fiddle : http://jsfiddle.net/wawawum/xak5bbv7/

Your Windows 8.1 install couldn’t be completed

Today my Surface Pro decided to stop working. My Windows Explorer process was freezing. I tried to solve the issue without success. Finally I tried the “Refresh your PC” option that reinstalled Windows 8. Then I tried to reinstall Windows 8.1 and get an error message : “Your Windows 8.1 install couldn’t be completed, try again later”.

I installed every missing Windows Update (115 updates), no success. Then I installed optional updates, no success. Finally I noticed that 15 apps (Modern UI Apps) were not up to date. You can see this in the Windows Store at the top right corner of the screen. After installing the updates for these apps, I was able to install Windows 8.1.

So when installing Windows 8.1 remember to :

– check Windows Updates

– check Modern UI Apps Updates