javascript - Disable the enter key chrome extension -
i want disable enter key in chrome extension using javascript particular page.for example : on login page, instead of pressing enter login user should click on log in button.
i using message passing in chrome extension.
document.addeventlistener("keydown", function(e) { var keys = e.which; chrome.extension.sendrequest({method: "gethtml", data: keys});
});
just call preventdefault() on handler consume event , stop it's propagation.
to make work on pages (not in every one), can create 2 content scripts: 1 enter prevention function , rest of functionality.
then include them on manifest this:
{ "name": "my extension", ... "content_scripts": [ { "matches": ["http://*/*"], "js": ["common_content_script"] }, { "matches": ["http://page_i_want_to_prevent_enter"], "js" : ["enter_prevention_script"] } ], ... }
Comments
Post a Comment