Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7815709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:36:20+00:00 2026-06-02T05:36:20+00:00

I have implemented the touch functionality to my website using these code and it

  • 0

I have implemented the touch functionality to my website using these code and it works fine for iPad/iPhone.

// registering touch events
function initTouchEvents() {

    // if a device is a touch device
    if (window.Touch) {
        document.addEventListener("touchstart", touchHandler, true);
        document.addEventListener("touchmove", touchHandler, true);
        document.addEventListener("touchend", touchHandler, true);
        document.addEventListener("touchcancel", touchHandler, true);
    }
}

// making items sortable in touch screen devices
function touchHandler(event) {

    var touches = event.changedTouches,
                    first = touches[0],
                    type = "";

    switch (event.type) {
        case "touchstart": type = "mousedown"; break;
        case "touchmove": type = "mousemove"; break;
        case "touchend": type = "mouseup"; break;
        default: return;
    }
    var simulatedEvent = document.createEvent("MouseEvent");
    simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY,
                                  first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);

    first.target.dispatchEvent(simulatedEvent);

    if (event.type == "touchmove") {

        event.preventDefault();
    }
}

But when I tested my website on touch screen PC, it doesn’t run and I found out that the window.Touch only run for iPhone/iPad. And I also tried various other events like typeof(window.ontouchstart != 'undefined') and ('ontouchstart' in window || typeof TouchEvent != "undefined") but it doesn’t detect that it’s touch screen and doesn’t register the event for touch movement.

What I am asking here is for an event in javascript that can detect all the touch devices (that IOS/Android/Windows/OSX) and run register the events.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:36:22+00:00Added an answer on June 2, 2026 at 5:36 am

    Phantom Limb makes desktop browsers simulate touch events

    https://github.com/brian-c/phantom-limb

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing a game which is having touch events and I have implemented
I have implemented tracing based on System.Diagnostics. I am also using a System.Diagnostics.TextWriterTraceListener, and
We have implemented a popup window as a modal dialog using the IE method:
I need to be able to detect touch events on the keyboard. I have
Fancybox has a full support and works fine on desktop platforms, however mobile/touch devices
I am writing an app for the iPhone using cocos2d where I have 4
I have already implemented multitouch image rotation using standard iOS graphics library (Core Graphics).
I have implemented a gallery where on touch the image is displayed at the
Currently I have a zoom implemented for my drawing application which works quite well.
I have a WPF 4 application where I have implemented Drag and Drop using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.