How to validate a key is pressed (just pressing, not holding) using the if condition in js?

I am well familiar with the functions addEventlistener and onkeyup, onkeydown which I can check the event holding keys:
var isKeyDown = false;
window.onkeydown = function (e) {
if (e.keyCode == 123)
isKeyDown = true;
};
window.onkeyup = function (e) {
isKeyDown = false;
};
function isKeyDown () {
return isKeyDown == true;
};

// Directly checking the conditions of the depression:
if (isKeyDown()) {
//do something...
}

But here's the thing! I don't know how to organize the check function key is pressed:
if (isKeypress()) {}
March 23rd 20 at 19:31
1 answer
March 23rd 20 at 19:33
Perhaps you will approach keypress
To read and play here: https://learn.javascript.ru/keyboard-events

Also notice that now when you have a keydown checks what key has been pressed, and keyup when the flag is reset by releasing any keys.
Yeah, I know about keyup - bert commented on March 23rd 20 at 19:36

Find more questions by tags JavaScript