admin管理员组文章数量:1331645
Currently I'm developing a LG webOS application (using Vue.js). Everything works fine, except the fact that when I press the back button on the remote, the back event does not fire. This causes that I'm forced to assign the function to go back to the previous page, to another button (which is not user friendly) instead of the normal return button.
(FYI: I'm using a webOS Signage display)
I've read the documentation about the history API and handling the back event (webOS Back Button) and tried the following, but none of what I tried works:
- Setting
disableBackHistoryAPI
to true inappinfo.json
and then manually catching the keydown event when the back button is pressed (keycode461
); - Setting
disableBackHistoryAPI
to false inappinfo.json
and then adding an eventlistener for thepopstate
event - Vice versa (cause you never know)
Even trying to catch the back button press event (so catching keycode 461
) doesn't work. The application recognizes all other keycodes, but pressing the back button simply doesn't do anything (fires no event). Anyone has any idea on this?
To be sure the problem is not per se application bound, I installed the following application Back Button Application. The same result: no back event.
Code to catch key event (logs all keycodes except 461
):
window.addEventListener('keydown', evt => {
evt = evt || window.event
console.log(evt.keyCode)
if (evt.keyCode === 461) {
router.go(-1)
}
})
The back button is being registered on the LG webOS emulator (v4.0). The framework I'm using as stated earlier, is Vue.js and I use Cordova Toast to pile my projects to LG webOS (and in the future to Samsung Tizen).
-- BOUNTY EXPIRED BUT STILL LOOKING FOR AN ANSWER --
Currently I'm developing a LG webOS application (using Vue.js). Everything works fine, except the fact that when I press the back button on the remote, the back event does not fire. This causes that I'm forced to assign the function to go back to the previous page, to another button (which is not user friendly) instead of the normal return button.
(FYI: I'm using a webOS Signage display)
I've read the documentation about the history API and handling the back event (webOS Back Button) and tried the following, but none of what I tried works:
- Setting
disableBackHistoryAPI
to true inappinfo.json
and then manually catching the keydown event when the back button is pressed (keycode461
); - Setting
disableBackHistoryAPI
to false inappinfo.json
and then adding an eventlistener for thepopstate
event - Vice versa (cause you never know)
Even trying to catch the back button press event (so catching keycode 461
) doesn't work. The application recognizes all other keycodes, but pressing the back button simply doesn't do anything (fires no event). Anyone has any idea on this?
To be sure the problem is not per se application bound, I installed the following application Back Button Application. The same result: no back event.
Code to catch key event (logs all keycodes except 461
):
window.addEventListener('keydown', evt => {
evt = evt || window.event
console.log(evt.keyCode)
if (evt.keyCode === 461) {
router.go(-1)
}
})
The back button is being registered on the LG webOS emulator (v4.0). The framework I'm using as stated earlier, is Vue.js and I use Cordova Toast to pile my projects to LG webOS (and in the future to Samsung Tizen).
-- BOUNTY EXPIRED BUT STILL LOOKING FOR AN ANSWER --
Share Improve this question edited Sep 3, 2019 at 7:04 Condor asked Aug 21, 2019 at 8:19 CondorCondor 1994 silver badges24 bronze badges 4- Can you please post the code where you are trying to catch the "keydown" event? – burakk Commented Aug 26, 2019 at 23:53
- @burakk added the code! – Condor Commented Aug 27, 2019 at 7:07
- Weird question, but is the key working generally ? Maybe there is a hardware issue with the remote if you can catch ANY other key except this one? – noa-dev Commented Aug 27, 2019 at 10:28
- @noa-dev to be sure, I tried a different remote but still the same problem. – Condor Commented Aug 27, 2019 at 10:31
3 Answers
Reset to default 3 +50Try adding this code into the head section of your index.html, and "disableBackHistoryAPI": true
into your appinfo.json
:
<script src="webOSTVjs-1.1.0/webOSTV.js" charset="utf-8"></script>
<script src="webOSTVjs-1.1.0/webOSTV-dev.js" charset="utf-8"></script>
<script type="text/javascript">
window.addEventListener("keydown", function(e) {
console.log("[keyCode] : " + "[" + e.keyCode + "]");
switch (e.keyCode) {
case 461:
console.log("Back key pressed");
webOS.platformBack();
break;
}
});
</script>
Please remember that ES6 is not supported in the LG webOS TV. I guess you already know that and use Babel to convert the code.
Please refer to this page for more information.
Were you able to use the BACK button on the remote control? I have the same problem here.
This code see the other buttons, except the back button.
window.addEventListener("keydown", function(inEvent){
if(window.event) {
keycode = inEvent.keyCode;
} else if(e.which) {
keycode = inEvent.which;
}
document.getElementById("BtnControle").innerHTML = keycode;
});
In my appinfo.json I added this: disableBackHistoryAPI: true;
from there the code below started to work:
<script type = "text / javascript">
window.addEventListener ("keydown", function (inEvent) {
if (window.event) {
keycode = inEvent.keyCode;
} else if (e.which) {
keycode = inEvent.which;
}
switch (keycode) {
case 461: history.back (-1); break;
case 38: document.getElementById ("TesteTit"). innerHTML = "up"; break;
case 40: document.getElementById ("TesteTit"). innerHTML = "down"; break;
}
});
</script>
If you can test it on your app, tell me if it worked.
本文标签: javascriptLG webOS back eventStack Overflow
版权声明:本文标题:javascript - LG webOS back event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742270335a2444185.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论