keyactions per keyboard instance
LiamFry opened this issue · comments
Is there a way to have a keyaction
list associated with a specific keyboard instance as opposed to "global?"
What I mean is this ...
When I have $("#input-in-ui").keyboard( { /*options ...*/ } );
everything within the "options" block is for that keyboard instance. However, $.extend( $.keyboard.keyaction, { ... } );
is "global" to all keyboard instances.
My application has one very custom input (a numpad with fractionals and units of weight), three boring numpad inputs (for quantities), and a full QWERTY (for entering custom text). As things are now, all five keyboards share the same $.keyboard.keyaction
object. The consequence of this, in my situation, is that I need to implement a single and somewhat "fat" bksp
handler that can accommodate every possible keyboard type. To pull this off, I need to resort to some custom variable witchery within the .keyboard()
options block.
Hi @LiamFry!
The keyaction
is globally defined, and I think keeping it that way may be more memory efficient. This might change in the next major release, if I ever get around to it.
So, I think a another solution for you might be to create a custom bksp
keyaction specific for the numpads, e.g. bksp-numpad
, and then use that definition in your layout instead of the provided bksp
.
Please let me know if that doesn't work out.
Thanks for the feedback. I'm already using a custom bksp
keyaction. The problem is that I have three different "backspace needs" since I have three fundamentally different keyboards: "weight quantity" (highly customized with fractionals and weights), "count" (just numbers and a decimal), and a reduced, simplistic "alphanumeric" (mostly QWERTY) - each with similar but different-enough "backspace needs."
That said, I think I found a solution. When setting a keyaction in the static $.keyboard.keyaction
list, any existing handler is replaced, e.g. if I use $.extend( $.keyboard.keyaction, { 'bksp': function ... } );
and bksp
already exists, it is replaced with the new definition. So what I'm doing now is setting the keyboard's unique backspace handler in the per-keyboard beforeVisible()
handler.