Search code examples
javascriptjquerytablet

how to detect if user is using windows tablet


my code isn't function well on windows tablet. I'm using slick-slider plug-in. and it should be deactivated if user are using touch devices. I've inspected my site on windows tablet and instead of having "touch" class i have "no-touch" here is my code

if( $('.no-touch').length ) {
    new Slider({
        element: '.theme-slider',
        slide: 'div',
        dots: false,
        infinite: false,
        arrows: true,
        slidesToShow: 2,
        slidesToScroll: 2,
    });
  }
});

how can i detect if my site is opend with windows-tablet


Solution

  • Maybe this will work for you :

    var isTouchDevice    = 'ontouchstart' in window || (navigator.msMaxTouchPoints>0);
    

    From:

    Detecting Windows Tablet (touch windows devices) with Jquery