keydown EventListener Firing Twice For Some Keys
Hey, any idea why the "keydown" event listener would be firing twice for certain keys (e.g. arrow key). I'm trying to adjust the listbox selection with the up and down arrow keys while inside the edittext box. Everything works but it fires twice and moves the selection down two spots.
Example code below... Thanks for any help!
// setup the dialog
var arr = ["Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6"];
var win = new Window("dialog");
var text = win.add("edittext");
text.active = true;
var list = win.add("listbox", undefined, arr);
list.selection = 0;
// move list selection with arrow keys while in edittext
text.addEventListener("keydown", function (k) {
alert("Pressed Key: " + k.keyName);
if (k.keyName == "Up") {
list.selection = list.selection.index - 1;
} else if (k.keyName == "Down") {
list.selection = list.selection.index + 1;
}
});
win.show();

