If I run this script it returns the same value regardless of the current keyboard layout.
How to subscribe on the keyboard layout changing?
const KeyboardLayout = require('keyboard-layout');
const Cron = require('cron').CronJob;
new Cron(
'* * * * * *',
function() {
const layout = KeyboardLayout.getCurrentKeyboardLayout().replace('com.apple.keylayout.', '');
console.log('layout', layout);
},
null,
true,
'America/Los_Angeles'
);