top | item 40236356

(no title)

mauvia | 1 year ago

It could work as an Array if javascript supports C++'s small-buffer-optimization on the backend.

discuss

order

keepamovin|1 year ago

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