I have an Ionic (5) app and I want to detect a long press on a key (keyboard) when the app is running on a mobile device (I'm testing on Android).
I added (keyup) and (keydown) to a ion-input, and when I run the app on browser I'm able to get the time difference between the first keydown event (if I long press on a key, keydown is firing multiple times) and the single keyup event that i receive when the key is released.
Unfortunately, this solutions isn't working on mobile (Android), I only receive one keydown event and one keyup event that fire almost at the same time, even if I press the enter key for more than 5 seconds or so.
I don't think any code is needed, since this one is more a conceptual question.
How can detect a long press on a mobile keyboard?
In android this isn't going to work. It's just not how the keyboard interface happens. By and large, keyboards don't actually send key events in Android. They send commitText messages, which just send a string to the text field. Anything turning it into key up and key down events is in the Ionic framework. Since the keyboard doesn't send key events, the app can't know how long they pressed the button. They keyboard doesn't send that info. So the Ionic framework that's making the key events can't give you that info either, there's no data for it to extrapolate from.
You're going to have to come up with a different UX design, this will never work on Android.
Related
I'm modifying ConnectBot to take advantage of hardware keyboards and I need to capture all Ctrl-? presses. I've disabled all of the alphabetic menu shortcuts (such as Ctrl-C for copy) but the key presses still don't seem to be being received by the onKey event.
I'm fairly new to Android development (literally started today to fix ConnectBot to handle hardware keyboards) and quick Google searching doesn't seem to turn up anything about capturing Ctrl-? key presses.
How do I tell Android to pass these straight through to the onKey handler?
It turns out that the keyCode was set to the correct character value (e.g. 'C'). However, the result of getUnicodeChar() was 0 because CTRL was being held.
All that was needed was to add handling to get the unicode character regardless of the meta-keys that are being held down with:
if (event.isCtrlPressed())
event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
Then later on it was necessary to encode the "CTRL is being held down" information in the key data that was being sent, which was already functionality provided by the ConnectBot code.
I read many answers on this topic and this is what i have understood
It is not possible to get any hardkey (home,menu,back,etsc ) press events from a service. It is not delivered to any service
For key camera button and media control broadcast events are sent if these applications are not already in the foreground.
So i need to conclude that it is not possible to launch an app by pressing a hardkey or a combination of hardkeys ie ( like home key 2 times or menu key and then back key ) ?
If this is the case how is samsung launching Vlingo when home key is pressed 2 times.
How this functionality is added to samsung galaxy
thanks a lot for your time and help
The Service Can not get the KeyEvent.
Sumsung can do it directly with the system rom. But we can not.
Our's is a mobile application developed using ADF mobile browser and myapache trinidad components.
We have a requirement of counting characters entered by the user in a . For it, we call a javascript on the onkeypress event of . The page works fine on iphone but in samsung galaxy, the event seems not to be fired. However, on the press of back and cancel button, the event fires well and displays the counter value. But it doesn't work with any other key. seems there is some issue with the keypad design of the phone. Is there any work around?
Is there a way to register a receiver for a app running in the background for when a user presses a key. Kind of like "ACTION_USER_PRESENT" but if any keys were pressed on the screen.
MORE DETAIL: My app is running as a service in the background. User opens the phone and presses keys, like they searching for something online on their driod. Can I capture those key presses in the background?
To detect whether a user is using the device you could also use the information whether the screen is on or off as an approximation (making the assumption that the screen timeout is set). This blog entry shows how to capture the screen on and off events (I haven't done it myself though).
In the Android HCI Extractor ( http://code.google.com/p/android-hci-extractor/ ) we traverse the GUI and install some event filters (by using listeners) in the app top view.
Maybe if you can reach a top level view from which listen the events you could listen to all the events for this view. Let's try ;-)
This tool is an open-source prototype you can find here: http://code.google.com/p/android-hci-extractor/
It is very easy to integrate and use. In the tutorials you can see that only a few lines of code are needed: http://www.catedrasaes.org/trac/wiki/MIM
I hope it helps you!!
I'm developing an Android program to analyze a user's text input and measure typing speed, error rate, average key presses to enter a single character. By doing so, I can compare characteristics of different input methods. To do this, I need to count and record all key presses made by the user during the text entry process.
For example, a user using a basic qwerty keyboard would have to press at least one key for each letter. However, a user using a keyboard with word completion would need to press fewer keys. But how many key presses are made (on average)? Does word completion actually improve typing speed? These are the questions my program will help answer.
Reading other posts, I know that (by default), onscreen keyboards don't send key events for all key presses. Physical (hardware) keyboards do, but most mobile devices don't have a physical keyboard. I also know that I can implement a TextWatcher to detect when a letter is typed in an EditText field. However, some IMEs might require the user to press a sequence of keys to enter a single letter (or word). I need to handle the intermediate key events (i.e., by counting and logging key presses).
My question: How would I capture every key press event from an IME (even events that don't trigger a typed character) without modifying the IME's user experience (e.g., auto completion, word prediction, T9 disambiguation, etc.)? Is this even possible?
Thanks in advance for your time.
Is this even possible?
Only by writing your own IME, AFAIK, or getting the source to an existing IME and instrumenting it.
did you try to listen for TouchEvents?
did you try to use onKeyPreIme() from View class? with this one you can catch key presses before they are consumed by the IME