Question

I'm doing some test webapps with firefox os(1.2) simulator and having trouble with keypress firing with the return key, works in firefox on mac as expected.

$(".null").keypress(function(e) {
    var inputText = $(this).val().trim();
    if(e.which == 13 && inputText) {
      var chunks = inputText.match(/.{1,1024}/g)
        , len = chunks.length;
      for(var i = 0; i<len; i++) {
        socket.emit('null', {
          msg: chunks[i]
        });
      }
      $(this).val('');
      return false;
    }
  });

I checked the docs and 13 is still the correct key so nothing odd or funny about it.. I also looked in something ffos webapps code on github to find other people using keypress but had no luck.

This should work shouldn't it?

Was it helpful?

Solution

I tried a simple event in 1.2 simulator and on the keon and it worked with the following code:

    window.onkeypress = keypress;

    function keypress(e) {
        console.log("keypress event detected!");
        if(e.which === 13 ){ 
            console.log("return presses");
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top