I thought the interesting thing was how it's a bitmask (a bit rare in IDL attributes / DOM properties). Also I was unaware there were 4th and (shock) 5th buttons for some mouses. So theoretically there's 32 possible states of pressing such a mouse.
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 :)
I feel like the bit flags structure of this event isn't Javascript-y because javascript doesn't support int primitives. Wonder why they didn't translate it.
That's what I thought it was, based on the name. But more interesting to see the bitmask heh :) I don't know about C++ internal, but in JS you can just go
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 :) haha
Heheheh. Well I guess we're getting down into the weeds now and into the aesthetics of it which are nevertheless personal.
To 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.
12 comments
[ 3.4 ms ] story [ 44.4 ms ] threadMozilla 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 :)
Is that right? And is it just specifically 10.5?
At least they didn't overcomplicate it. I shudder to think of: MouseEvent.MIDDLE_BUTTON_PRESSED etcs.
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
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? :)