Computed Knockout JS function seems not unbind in firefox for keypress event

55 Views Asked by At

I'm using the following function with knockout

 self.navigateToSection = ko.pureComputed({
        read: function() {
            return this;
        },
        write: function(data, event) {
            if (event.type == "keydown") {
                if ((event.keyCode != '13')) {
                    return;
                }
            }
          ... (more actions)
        }//write
    });

this is the HTML binding

data-bind="event: {keypress: navigateToSection}">

The function should help to navigate between different sections so the user must to be able to press the tab key and jump to a different link. it works well for most of the browser except for firefox in Windows 10 it's working fine in Mac for Firefox

I found that keypress event is no longer fired for non-printable keys, except for the Enter key, and the Shift + Enter and Ctrl + Enter key combinations for Firefox. So when I press tab it seems stock there instead to jump to the next HTML element with a tabindex attribute if I blur the element it allows to jump even in FF but just until the second keypress.

I try to unbind the element but it does not work well. Any ideas?

1

There are 1 best solutions below

0
Brother Woodrow On

The keypress event has been deprecated. You should use keydown instead.