Hello, there. Any other suggestions on this? My current situation: - Shift+numpad numbers: captures only the number - Shift+keyboard top numbers: captures both (shift and the number) - Shift combinaded with Ctrl or Alt and numpad numbers: shift is ignored - Shift combinaded with Ctrl or Alt and keyboard top numbers: all captured - The Alt+Number alert I set only works with numpad numbers I'm using Windows 10 and InDesign CC2020 and CC2021 (same behavior). I tried the "keyup" event listener inside and outside the "keydown" event listener. Same result on both sides. Thank you so much. I'll really appreciate any help! main();
function main() {
var w = new Window("dialog" , "Script by LFCorullón");
var e = w.add("edittext" , [0,0,140,24] , "");
e.active = true;
e.addEventListener("keydown" , keypress);
function keypress(k) {
str = [];
if (k.ctrlKey) str.push("Ctrl");
if (k.altKey) str.push("Alt");
if (k.metaKey) str.push("Win");
if (k.shiftKey) str.push("Shift");
e.addEventListener("keyup" , keyup);
function keyup(k) {
if (k.keyName >= "0" && k.keyName <= "9") {
str.push(k.keyName);
if (str.join("+").match(/\d\+\d$/gi)) str.splice(-1 , 1);
e.text = "";
e.text = str.join("+");
}
}
}
e.onChanging = e.onChange = function () {
if (e.text.match(/\d\+\d$/gi)) {
e.text = e.text.replace(/\+\d$/gi , "");
}
if (e.text.match(/^.(?=(alt|shift|ctrl))/gi)) {
e.text = e.text.replace(/^(.)(alt|shift|ctrl)/gi , "$2");
}
if (e.text.match(/^alt\+\d$/gi)) {
e.text = "";
alert("Alt key must be used in conjunction\rwith another modifier key (Ctrl or Shift)." , "Script by LFCorullón" , true);
}
}
w.show();
}
... View more