Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Feedback
  3. Add blocks for detecting mobile devices/touchscreen

Add blocks for detecting mobile devices/touchscreen

Scheduled Pinned Locked Moved Feedback
feature-request
4 Posts 2 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JaecadeJnightJ Offline
    JaecadeJnightJ Offline
    JaecadeJnight
    Mod Helper
    wrote on last edited by
    #1

    I have somewhat of a solution to this by regex checking if the user agent contains “Android” or “Mobi” or some other stuff (to see if a user is using mobile), but JavaScript provides other methods like checking navigator.maxTouchPoints (to check for touchscreen) and all.

    I want to use this to detect if the user is using mobile/touchscreen, and then provide joysticks for my 3D scene. I propose two new blocks:

    • Sensing reporter block: (is touchscreen?) , uses navigator.maxTouchPoints and checks if it is above 0. If it is above 0 then there’s touchscreen, but if it isn’t then its a computer.
    • Sensing reporter block: (is mobile?) , is more general, and would generally mean touchscreen and no keyboard. This would be most useful for detecting then adding joysticks in my code.

    My current method for seeing is the user agent is mobile is also kind of frowned upon and doesn’t always work because users can enable “Desktop mode” in their mobile browsers which would make the game unplayable. There’s also like different browsers too

    #LLJW
    <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

    1 Reply Last reply
    1
    • Tyller_T Offline
      Tyller_T Offline
      Tyller_
      trusted helpers
      wrote on last edited by
      #2

      @jeffreyrb03-gmail I dont think you can directly detect touchscreen but you can definetly detect if its mobile (like you said with user agent) because devices might not broadcast touch screen support, though you could detect as soon as a touch is detected, though I think you have to detect touch differently than mouse clicks (pretty sure) so you can even detect if touchscreen was last used

      <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
      </div>

      JaecadeJnightJ 1 Reply Last reply
      0
      • Tyller_T Tyller_

        @jeffreyrb03-gmail I dont think you can directly detect touchscreen but you can definetly detect if its mobile (like you said with user agent) because devices might not broadcast touch screen support, though you could detect as soon as a touch is detected, though I think you have to detect touch differently than mouse clicks (pretty sure) so you can even detect if touchscreen was last used

        JaecadeJnightJ Offline
        JaecadeJnightJ Offline
        JaecadeJnight
        Mod Helper
        wrote on last edited by
        #3

        @tyller_ yeah true, ontouchstart events and navigator.maxTouchPoints do mean touchscreen tho

        #LLJW
        <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

        Tyller_T 1 Reply Last reply
        0
        • JaecadeJnightJ JaecadeJnight

          @tyller_ yeah true, ontouchstart events and navigator.maxTouchPoints do mean touchscreen tho

          Tyller_T Offline
          Tyller_T Offline
          Tyller_
          trusted helpers
          wrote on last edited by
          #4

          @jeffreyrb03-gmail yeah but with some touchscreen it allows for mouse and touchscreen, so maybe header blocks for when touchscreen started and when non touchscreen started? or just a booolean for if touchscreen is in use (whether last press was mouse or touchscreen) then manually detect changes and run scripts (toggling joysticks etc)

          <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
          </div>

          1 Reply Last reply
          1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • CreatiCode