alert_words_ui: Use e.key instead of deprecated e.which.

Tested by making sure alert word is added when Enter is pressed in
the alert word input.
This commit is contained in:
Priyank Patel
2021-05-31 16:29:58 +00:00
committed by Tim Abbott
parent 98cb0e339c
commit 969874d633
2 changed files with 3 additions and 4 deletions

View File

@@ -111,7 +111,7 @@ run_test("add_alert_word_keypress", (override) => {
const event = {
preventDefault: () => {},
which: 13,
key: "Enter",
target: "#create_alert_word_name",
};

View File

@@ -97,9 +97,8 @@ export function set_up_alert_words() {
});
$("#create_alert_word_form").on("keypress", "#create_alert_word_name", (event) => {
const key = event.which;
// Handle Enter (13) as "add".
if (key === 13) {
// Handle Enter as "add".
if (event.key === "Enter") {
event.preventDefault();
const word = $(event.target).val();
add_alert_word(word);