You will have to use innerWidth instead of width property for that purpose.
    $window.innerWidth 
or try this
    $window.screen.width
3
solved JQuery distinct between smartphones, tablet or computers with different sizes but the same $(window).width()