Search code examples
javascriptjqueryprimefaceskeyboardkeyboard-events

jQuery Keypad / Primefaces keyboard re-map spacebar


I face issue with jQuery Keypad / Primefaces keyboard - I try to re-map default spacebar button to input hex value '32' instead of '160'. Because when I type "space" from my phisical keyboard then it gives different value (32) then from virtual one (160)

Any solutions? Because I try to avoid writting my own component.

Big thanks in advance.


Solution

  • If someone struggle with same problem.

    I have fix it by override _generateHTML function inside keyboard.js from Primefaces 6.1 . For next version it will be configurable, but for this I will change (line 717):

    (keys[j] == this.SPACE_BAR ? ' ' :
    (keys[j] == ' ' ? '&nbsp;' : keys[j]))))))) + '</button>'));
    

    To:

    (keys[j] == this.SPACE_BAR ? ' ' : keys[j])))))) + '</button>'));
    

    And for me works fine.