OnKeyPressed and OnKeyReleased on FR230, 235 & 735

hi,

I would like to catch the event of holding the Up or Down keys. Doing something like:
class MyDelegate extends Ui.BehaviorDelegate {
...
function onKeyPressed(evt) {
if (evt.getKey() == KEY_UP) {
// do something
}
else if (evt.getKey() == KEY_DOWN) {
// do something
}
}

function onKeyReleased(evt) {
//similar to the above
}

That works fine for all watches in the emulator, and also work fine on my physical Fenix 3. However, user reported that on their actual 230, 235 and 735 my app doesn't respond to the Up / Down key presses. I also experienced a similar issue in these devices trying to catch KEY_ENTER / KEY_ESCAPE keys, but in this scenario I could cope with catching the behavior OnSelect() / OnBack(). However, with the Up / Down key I really have to know when they were pressed and when released.
Is there something specific to 230 / 235 / 735 that should be done differently to catch these keys? Should I attempt to catch something from the extended keys? Is there a reason it works on the emulator but not on the actual device?

Thanks for the help!
  • This is a known issue. You can read about it here.
  • It says I don't have permissions to view that thread.
  • Oh ok. Saw those threads prior to posting the question but I didn't and still don't understand what's the bottom line, so apologies for posting a question that was more or less already asked.

    What's the known issue then - (a) are the devices above don't fire OnKeyPressed at all? Or (b) are they firing it but the key that's sent is not what I would expect? At my first version I returned "true" for any key in OnKeyPressed, and handled by myself the keys, including Back / Escape. People had complained that they cannot exit from my app on those devices, so maybe (b) above is the issue?

    And, why on the emulator keys behave differently (apparently) compared to the actual device? As I mentioned, in the emulator everything works as expected with those devices, OnKeyPressed is fired with the expected key, and so does OnKeyReleased. I don't have actual 230/235/735 to test with.

    And is there a workaround to handle holding the physical key? Should I use OnKey() together with OnKeyReleased() for example? Or OnKeyPressed but use different key code?
  • What's the known issue then - (a) are the devices above don't fire OnKeyPressed at all? Or (b) are they firing it but the key that's sent is not what I would expect?

    The bottom line is that the onKeyPressed() and onKeyReleased() functionality doesn't work, or at least doesn't work with many devices, at this point in time. I tried to capture what I knew about the problem at the time in this post. On all the devices I tested, except one, the functions weren't called at all.

    At my first version I returned "true" for any key in OnKeyPressed, and handled by myself the keys, including Back / Escape. People had complained that they cannot exit from my app on those devices, so maybe (b) above is the issue?

    If you returned true then the engine would think you handled the key press event. If the onKeyPressed() callback was invoked, and you called Ui.popView() from the last view, the app should exit. If the callback wasn't invoked, then I'd expect onKey() to be invoked, and you'd get whatever behavior was implemented there (or the default).

    And, why on the emulator keys behave differently (apparently) compared to the actual device?

    This should probably be considered a simulator bug. The simulator is behaving the way that they want things to behave, not the way they actually behave, which can cause problems if you develop the application without testing on a physical device. I'll be sure to bring this up with the Garmin guys.

    And is there a workaround to handle holding the physical key?

    No. To be safe, you should avoid using onKeyPressed() and onKeyReleased(). This may mean that you'll have to change how your application works.

    Travis