LoginSignup
0
0

More than 5 years have passed since last update.

Fitbit ionic 「document.onkeypress」が「back」しかハンドリングしてくれない!

Last updated at Posted at 2018-03-28

環境

Fitbit ionic
Fitbit OS 2.0(27.32.4.19)

起きたこと

「document.onkeypress」でボタンの動作をハンドリングするも、「back」しか反応しない。

コード

  document.onkeypress = function(evt) {
    console.log("Key pressed: " + evt.key);
    if (evt.key === "back") {
      evt.preventDefault();
    }
  }

原因

guiファイルでコンボボタンを定義していたのが原因でした、

※抜粋
<use id="btn-tr" href="#combo-button-upper-right" fill="fb-red">
    <set href="combo-button-icon" attributeName="href" to="btn_combo_pause_p.png"/>
    <set href="combo-button-icon-press" attributeName="href" to="btn_combo_pause_press_p.png"/>
    <set href="combo-button-stroke" attributeName="display" to="inline"/>
  </use>
  <use id="btn-br" href="#combo-button-lower-right" fill="fb-peach">
    <set href="combo-button-icon" attributeName="href" to="btn_combo_play_p.png"/>
    <set href="combo-button-icon-press" attributeName="href" to="btn_combo_play_press_p.png"/>
    <set href="combo-button-stroke" attributeName="display" to="inline"/>
  </use>
</svg> 

上記コードを削除すると、upもdownもハンドリングされました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0