MCPcopy
hub / github.com/g3n/engine / getModifiers

Function getModifiers

window/canvas.go:479–499  ·  view source on GitHub ↗

getModifiers extracts a ModifierKey bitmask from a Javascript event object.

(event js.Value)

Source from the content-addressed store, hash-verified

477
478// getModifiers extracts a ModifierKey bitmask from a Javascript event object.
479func getModifiers(event js.Value) ModifierKey {
480
481 shiftKey := event.Get("shiftKey").Bool()
482 ctrlKey := event.Get("ctrlKey").Bool()
483 altKey := event.Get("altKey").Bool()
484 metaKey := event.Get("metaKey").Bool()
485 var mods ModifierKey
486 if shiftKey {
487 mods = mods | ModShift
488 }
489 if ctrlKey {
490 mods = mods | ModControl
491 }
492 if altKey {
493 mods = mods | ModAlt
494 }
495 if metaKey {
496 mods = mods | ModSuper
497 }
498 return mods
499}
500
501// Canvas returns the associated WebGL WebGlCanvas.
502func (w *WebGlCanvas) Canvas() js.Value {

Callers 1

InitFunction · 0.85

Calls 1

GetMethod · 0.80

Tested by

no test coverage detected