I
I
Ivan Ponomarev2021-07-01 00:08:49
JavaScript
Ivan Ponomarev, 2021-07-01 00:08:49

Why is one of the three associative array values ​​in input displayed incorrectly?

i prints 1 , l prints 7. But o prints o.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2021-07-01
@9vanya

The error you are asking about is in the equals sign.
if(event.key = a8[event.key]){- here you simply assign to the event.keyvalue from a8. When you enter a small "o", zero is returned, and if ()does not work. In the other two cases, a non-zero is returned, and the code inside the if ().
In general, it seems to me that it is necessary not to respond to key events, but to any change in the input field - for example, copied text can be inserted there. And you need to show not a single character, but the entire line.

spoiler

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question