Hello, can someone explain what is the difference between these 2?
I use the following logic:
if (event.key === "Enter" && !event.shiftKey) { event.preventDefault();
if (event.key === "Enter" && !event.shiftKey) { event.preventDefault();
The idea is, if I press enter ONLY, that is I can't press 2 keys at the same time, then prevent default but if I press enter and shift simultaneously, then normal behaviour. At first I try to use
event.key
event.key
2 times but it seems it wasn't working or I was getting an error (don't remember exactly).
Can someone explain why we would need a logic as above to act as if "IF only enter is press and no shift key along, then do something" pls.