How to implement a hot key on a mobile app

How to implement a hot key on a mobile app

  

Hello, 

I have a mobile app with offline functionality. I have an action on a screen that must be executed every time that a user press a left or right arrow key on the keyboard. So, no matter where the user is in the screen, whenever the arrow is pressed the action must be executed. Like pressing the windows key on a windows machine. You can press it anytime in any application and the windows menu will pop up.

I tried the OSKey component but that only works for web apps. I also searched for a cordova plugin but could not find anything.


Alternatively I need a method to always keep the focus on a specific field on the mobile app that I can use to capture the arrow key press. So, is a user does a click or enter a value in a field elsewhere on the app, then the focus must immediately return to the field that I am using to "listen" to the arrow.  How can that be done?

Does anyone have any ideas on what I can do?


Thanks!


Solution

Hi Vonnelize,

As I understand it, you can capture any key using JavaScript (though I'm not an JavaScript expert by far). You could add the JavaScript to a Block that you add to the header or footer of the Theme you are using for the Mobile App.

Solution

Kilian Hekhuis wrote:

Hi Vonnelize,

As I understand it, you can capture any key using JavaScript (though I'm not an JavaScript expert by far). You could add the JavaScript to a Block that you add to the header or footer of the Theme you are using for the Mobile App.


Hi Kilian, thanks for the response. I asked a friend that knows javascript to help me and we manage to get it right. He will be posting the solution as a component soon. I will then update this thread.

Hi Vonnelize,

Great you got it solved, and even greater it'll be a component in the Forge!