2
我試圖檢測用戶在xul文本框(Firefox擴展)中點擊轉義或輸入時。但是下面的代碼似乎不起作用。任何援助將不勝感激。XUL文本框addEventListener
const KEY_ENTER = 13;
const KEY_ESCAPE = 27;
function keyPressed(e) {
switch (e.keyCode) {
case KEY_ENTER:
// do something
break;
case KEY_ESCAPE:
// do something
break;
}
}
var textbox = document.getElementById("mytextbox");
textbox.addEventListener('keypress', keyPressed, true);