我有一个使用 jqlite 的 Angular 指令,我想绑定一个按键、按键和粘贴事件来更新指令上的选项。
我使用以下方法绑定到 paste、keypress 和 keydown 事件:
input.bind("paste.elementClass", updateOptions);
input.bind("keypress.elementClass", updateOptions);
// keypress does not fire if the backspace/delete button is pressed. This keydown listener triggers the
// keypress event if backspace/delete is pressed. Didn't use keydown listener instead of keypress because
// keydown did not register if multiple buttons are pressed (shift + d). The keyup event choked
// if a button was pressed and held for longer than the model debounce time.
input.bind("keydown.elementClass", function() { …Run Code Online (Sandbox Code Playgroud)