MouseEvent: buttons property
developer.mozilla.org
developer.mozilla.org
Mozilla dev docs are great, nice to see them getting to the top of HN :)
But why just MouseEvent.buttons?
I wasn't aware JS surfaced this "multi touch" capability for buttons, as the bitmask indicates which buttons were pressed "at the same time" for whatever the event is (mouse/pointer down etc). Just thought it was cool and a little rare.
Nice digging into the MDN docs and discover new parts of the DOM. Like a new room in a giant familiar house! :) For me at least haha :)
At least they didn't overcomplicate it. I shudder to think of: MouseEvent.MIDDLE_BUTTON_PRESSED etcs.
if ( mousedown.buttons & 4 ) alert('aux pressed')
Tho thinking of it now as you mentioned array I'd feel mousedown.buttons.includes(4) would be slightly inefficient due to the loop. We like our efficiency! Haha :)For me tho the API feels right for JS. As it's kind of a rare a 'low level' thing, it's appropriate it's API is more akin to that than something heavier like
MouseEvent.buttons.<button> = Boolean
I like the efficiency of the bit mask to immediately check multiple buttons too :) hahaTo me, it's obscene and ugly. Over the top. 4 isn't so magic when you realize that the middle button is normally considered the 3rd after the first and second buttons. And when you stretch those values into a bit field, with zero representing nothing, it's natural that the middle (or aux button) will occupy 4.
Hahaha! :) At least to my thinking. Hahaha :)
What do you think? :)
Is that right? And is it just specifically 10.5?