Closed tobiasvandriessel closed 7 years ago
Hi @tobiasvandriessel!
Yes, it's not built in, maybe it should be, but you can use the "keysetChange" event to check (demo):
$(function() {
$('#keyboard')
.keyboard({
layout: "international"
})
.on('keysetChange', function(event, keyboard, element) {
// keyset changes before keyboard is visible
if (keyboard.isVisible()) {
var keyset = keyboard.$keyboard.find('.ui-keyboard-keyset:visible');
console.log("current keyset = " + keyset.attr('name'));
}
});
});
or, you can check individual keysets:
keyboard.shiftActive // true when shift is active; false when not
keyboard.altActive // true when alt is active; false when not
keyboard.metaActive // contains the string name of the meta set when active; false when not
Ah thanks! That's exactly what I needed! :) Btw, can there be any more customLayouts and can the alternative keysets have names different from shift and metaX? Right now I use 3 layouts (probably going to trim that using the keysets, so using natural names instead of metaX might just come in handy) using `$.keyboard.layouts.NAME = {"default" : []}', which you strongly advise against haha.
The meta1
, meta2
, .... metaN
naming are only used internally by the plugin. You can change what is displayed using the display
option... see the docs on how to define meta keys.
Actually, the way the code is set up, you could add an underscore in the meta key name to describe it... something like meta0_symbols
or meta1_greek_alphabet
- see http://jsfiddle.net/egb3a1sk/2158/
Ah nice, that's really useful! I didn't realize that this was the way to go as I used the different layouts initially. Thanks again! :)
I just released v1.26.8, and you can now name the meta keys as follows:
meta0
(still allowed), metakeys
, meta_symbols
, meta-greek
.meta
followed by any of the following characters A-Za-z0-9_-
.Sadly, I was going to add a new getKeySet
function which would return the current keyset, but I forgot
Ah very nice! More freedom :)
Haha, don't worry about it, it's a small thing really :p
Done!
Aw yeah! :D
Hi @Mottie,
One last question: Is it possible to get the current active keyset?