언어 설정

Menu
Sites
Language
How to implement rotary event on a keyboard?

Hello,

I would like to use the rotarydetent event to change
the keyboard layout but it does not work on the gear s2. For a normal app, I can use
rotarydetent by adding a eventlistener on load.

Things I have tried:

- Write a anonymous function that executes itself. Inside the
function, add the eventlistener.
- Add the document.addEventListener("rotarydetent") to onInit or onShow.

Nothing works. I have added input.rotating_bezel in the config file as well.

I would be really appreciate if you can shed some light on this matter.

 

Responses

3 댓글
Md. Anwar Parvez

Hello Le Hoang,

You can't get an onShow event directly in JavaScript. Please note that the mentioned methods are non-standard (onShow is supported by only Mozilla Browser).

To bind an event callback on rotary events, use the following code on load or on other event(e.g. click, touchstart etc):

 

document.addEventListener("rotarydetent", function(ev) 
{
   /* Get the direction value from the event */
   var direction = ev.detail.direction;

   if (direction == "CW")
   {
      /* Add behavior for clockwise rotation */
      console.log("clockwise");
   }
   else if (direction == "CCW")
   {
      /* Add behavior for counter-clockwise rotation */
      console.log("counter-clockwise");
   }
});

 

This article may also help -> https://developer.tizen.org/dev-guide/2.3.1/org.tizen.gettingstarted/html/web/details/event_handling_w.htm#rotary

For any further information, please feel free to ask.

Heng Liu

Hi there,

The code you wrote is correct, however, this part of code will not work in an wearable IME application. I met the same problem, still look for solutions.

Also, 

<tizen:setting hwkey-event="disable"/>

will not work either.

If you make any progress, please let us know.

Thank you.

Heng Liu

Hi there,

I met the same problem. Do you have any solution now?