環境
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もハンドリングされました。