Dual Purpose Buttons - i.e. Lap / Back - Key Events

Hello there,

I'm wondering what's the best practice for using the button for dual purpose? 

To be more specific I would like program the Lap/ Back Button to perform this operation:

Lap Button => Reset the Timer

Back Button => Exist the application

I can come up a solution by using the  onKeyPressed() & on KeyReleased() callbacks but I'm little surprise that SDK doesn't already have this functionality in it.

The ideal solution I would like to have is simply have the needed process in the onKey() callback for the the Key_LAP & KEY_ESC.

Also, where in the documentation I can find when the following key events are fired: KEY_ESC, KEY_RESET, KEY_LAP?

Thanks

Shawn

  • Some of this depends on the device,  For example, Edge devices have a seperate lap button,  On things like a venu with 2 buttons, a press of the bottom button is onBack, while a long press of the same button is onMenu.  On 5 button watches, a press of the middle left button is "up", while a long press of the same button is onMenu.  On music devices, a short press of the lower left button is "down" and the default is a long press is for music.

    Using onKepRessed and onKeyReleased is risky in general, but the dual use buttons make it worse.

    on watches, a press of the lower right button is determined in the app.  For example, if I have a device apps that records, when recording I treat it like a lap button.  If not recording, I exit.

    Some devices have many more buttons than others. Such as the GPSMAP devices.

    Using the input sample in the SDK, you can see what buttons do on various targets.

    Here you can see buttons by device:

    https://developer.garmin.com/connect-iq/reference-guides/devices-reference/#devicereference

  • On general, you may want to use stuff on onBack(), onMenu(). onSelect(), onNextPage(), onPreviousPage() instead of onKey() as they work with touch or button devices.  onNextPage and onPreviousPage work for up/down buttons or up/down swiples for example

  • Thanks Jim for this information, it really explains a lot now.  

    Do you know why most of the watches doesn't support the KEY_LAP Event, although most the modern watches do have dual purpose button for the Back / Lap Button? How do developers usually handle this dual operations for this button for stuff like a Stopwatch application? 

    Jim, I'm curious about your comment, would you consider this risky?

    Using onKepRessed and onKeyReleased is risky in general, but the dual use buttons make it worse.

    Do you know when the onNextMode() and  onPrevMode() callbacks are called?

    Thanks again for the help

    Shawn

  • Do you know why most of the watches doesn't support the KEY_LAP Event, although most the modern watches do have dual purpose button for the Back / Lap Button?

    It's only on devices that have a separate lap button.

    Do you know when the onNextMode() and  onPrevMode() callbacks are called?

    I've never used them or looked into them.  I expect they might be on devices with a whole bunch of buttons like the GPSMAP