Creating mobile controls for Javascript app (keyboard sim) - javascript

There's a game in Javascript which used the keyboard for controls to move the player. I'm wondering how you'd go about converting this to a mobile version.
I would need to allow the user to press graphic buttons on their phone to essentially simulate keyboard presses (and releases) and utilize multi-touch as well.
Any ideas on the best way to go about this? I have a few ideas, but I'd hate to start trying to implement one and find out it doesn't work.

Related

Disable Chrome mobile's "tap to search" on a web app

I would like to be able to disable, through JavaScript or some sort of HTML meta-tag, the tap-to-search/touch-to-search feature found on mobile Chrome which shows a banner at the bottom of the browser every time the user long presses/taps on a word in any text paragraph.
This Chrome feature is a problem for me because this contextual banner completely covers the toolbar in the web app that I am developing, which is fixed at the bottom of the page.
I've only found this question from 2015 which references this Google Developers article (also from 2015), but the proposed solutions do not seem to work anymore except CSS "user-select: none"; unfortunately, disabling user selection is not a solution for me since user selection is required for my web app to work.
I have also tried setting event.preventDefault() when the "oncontextmenu" event fires, which does disable the search toolbar when the user taps on a word, but not when a user long presses on a word, as far as I have experienced.
So far the only partial "solution" that has worked for me has been to install the web app: as an installed PWA, tap-to-search does not somehow trigger. It still annoys me a lot that I would have to basically beg my potential users to install the web app on mobile.
I also know that the user can manually disable this feature globally in the Chrome Flags, but this is, I imagine, really annoying for a potential user as well.
Is there anything I am missing here? Do you know of any way to prevent tap-to-search from firing on a long press?
Adding the attribute tabindex="-1" to the <body> tag works for me.
As of 2021, it isn't possible to disable touch-to-search (when this is triggered by a long-press for text selection) in chrome mobile. The Google Developers article is apparently concerned only with touch-to-search triggered through a tap gesture.
Quoting donnd, from bugs.chromium.org:
Regarding #2 -- developer control: The 2015 article that you mentioned (https://developers.google.com/web/updates/2015/10/tap-to-search) focuses on triggering through the tap gesture. As you correctly point out, it does not address the long-press gesture triggering. Touch to Search responds to both tap and long-press but treats them differently. As I'm sure you know, the long-press gesture activates a whole set of features which can include copy, translation, smart text selection, and Web Search. A site developer can markup their page text as non-selectable in order to disable the long-press gesture entirely, but currently there's no way to disable only the Touch to Search response to long pressing. If you'd like to work with us to add such a feature, let us know and we'll file a separate feature request.

How to create button for mobile to scan Barcode using html5 jquery or javasctipt?

Is there any way to trigger mobile phone camera to scan Barcode from html using jquery or javascript ?
I would like to create form and then button (when you clicked on mobile it will let you scan code and it will place the code on input field)
Is that possible?
You might want to look at: https://serratus.github.io/quaggaJS/
I haven't used it in any production code yet but have experimented with it. Scanning good quality barcodes works well. Scanning through plastic bags and shrink wrap is a bit iffy. (To be fair, dedicated scanners also have issues there, but tend to do better.)
Tested only on Android with Chrome and Firefox. Requires the most recent iOS/Safari to work on that platform.

How to show native jwplayer play button on iPhone

I'm trying to make jwplayer show the native iPhone play button (see below) on iPhone, and a custom skin elsewhere. I've tried to use chromeless: true, but it didn't help (I still get the skinned play button). Now I'm stuck in jwplayer code and can't find my way through. Can you help me out?
I'm afraid we fail back to the default iOS tag so it is not possible to show our native play icon. However, in a future release we plan on adding out own mobile UX/UI, so this will be possible then!

how to keep track of play and pause events on an embedded blackberry media player on a website?

I'm using an embedded media player on my website to allow blackberry users to listen to audio without having to download it. (I'm testing this on blackberry bold 9700 and so any cool html5, flash or embed tags wont work) The reason I have it embedded is because I want to be able to keep track of a users listening time.
Basically what I want is to be able to know when a user clicks play or pause. How do I gain control of these buttons? possibly using some jquery?
This is my code for the player:
<object data="myfilepathHere" type="audio/mpeg">embedded track isnt working!</object>
This is the site I used as a reference:
http://devblog.blackberry.com/2009/08/blackberry-browser-embedded-media-content-automatic-playback-how-to/
I can get the two buttons play/pause and stop to show up (and it looks just like it does in the link I've provided) on the blackberry and the track to play so if I can get this to work that would be just dandy. thanks! :D
Sorry, I spent some time trying some ideas out and I'm pretty certain it's not possible to track or listen to any events on the Object. You really need the Audio tag on BBOS 6.0 and higher. If you were doing a WebWorks app instead of a website we have an API that would help (https://developer.blackberry.com/html5/apis/blackberry.audio.player.html).
Supporting 6.0+ is not that bad. You may find that the majority of people who visit your site have that version or higher.

Set keyboard to stay open even on "go" press with html5/javascript?

I'm building a small html5 web-app to hone my html5 skills. I've built the project and it works pretty good, but I want to enable some mobile functionality which should make it even cooler! One of the annoyances of using the site on mobile is that whenever you press the "go" button on the android keyboard after entering data into a textbox, it hides its self, despite the fact that in javascript I've specified that the textbox still has focus. Is there a way to explicitly tell the android browser to keep the keyboard open?
Thanks,
John
I think this is beyond the realms of JS - The keyboard is part of android, and thus (I assume) would be up to the browser to decide whether the keyboard stays or not - how would you cope for different browsers running across android?
Because I would assume they're not all running Webkit (Firefox mobile?).
So I think the answer is it can't be done :(

Categories