I saw this code here:
myCombobox.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
myCombobox.close();
event.stopPropagation();
}
});
My education and experience tells me that the code should be comparing a constant.
myCombobox.addEventListener(MouseEvents.KEYDOWN, function(event) {
if (event.key === KeyboardConstants.ESCAPE) {
myCombobox.close();
event.stopPropagation();
}
});
Is there a class or object in JavaScript that has a list of all the keys and keyboard events on it?
Other languages do this for very obvious specific reasons, to prevent typos, which prevent errors and non-functioning code.
Does Javascript love errors or do these classes exist and I couldn’t find them?
I tried to suggest this to TC39 and they said it’s not a language feature. Where do I suggest this feature?