この典型的な状況でBackspace、ナビゲーションを元に戻すことができないという問題があります。しかし、私が思うに違いがあります。
それは私の焦点を合わせたオブジェクトのonKeyDown
機能です。(もちろん多少の変更はあります)
function(key) // Key is the pressed key code
{
return key != 8;
};
上記の関数は正しく実行されますが、以下の関数は実行されません。
function(key) // Key is the pressed key code
{
wnd.onKeyDown(key);
return key != 8;
};
wnd
はオブジェクトとそのonKeyDown
機能です:
this.onKeyDown = function(key)
{
if (key == 37)
this.charInd = Math.max(0, this.charInd-1);
else if (key == 39)
this.charInd = Math.min(this.string.length-1, this.charInd+1);
else if (key == 8)
{
this.string.splice(this.string.length-1, 1);
this.charInd--;
}
};
ナビゲートを防ぐために、フォーカスされたオブジェクトの関数を送信することだけが重要ではありませんtrue
か?false
onKeyDown