Search code examples
javascriptasp.netsamsung-smart-tv

Handly keypress on smart tv browser


I have developed restaurant ordering application that kitchen has a tv to monitor orders and when job ready need to press for example 1 to completed order but on samsung smart tv browser keypress is not fire , any solution?

Many thanks in advance.


Solution

  • For capture onkeydown event in Samsung browser you need to set focus to the some object which have this handler, for example to body:

    window.onload = function()
    {
          document.body.focus();
    }
    window.onkeydown = function(event)
    {
          alert(event.keyCode);
    }
    

    Important to know - Samsung intercepts alert() and not shows it in popup, so, you will not see them. Instead of this, you can write your own handler:

    function alert(s)
    {
           document.getElementById('alert-block').innerHTML = s;
    }