msgProc: Reference

Complete listing of message type constants, modifier flags, virtual key codes, and API functions. For how Win32 concepts map to the DOM, see the Architecture page. For concepts and examples, see the msgProc Guide.

Message Type Constants

All message types available in msgProc. Use these constants to identify which event occurred:

Constant Hex Value Description
MSG_UNKNOWN 0x0000 Unknown or unhandled event
MSG_DESTROYED 0x0002 A direct child component was destroyed. event.detail.childPacId contains the destroyed component's pacId. Dispatched asynchronously to the parent after the child has fully cleaned up.
MSG_SIZE 0x0005 Container changed size. wParam is a SIZE_* constant (SIZE_RESTORED, SIZE_HIDDEN, or SIZE_FULLSCREEN). LOWORD(lParam) is the new width in pixels; HIWORD(lParam) is the new height. event.detail also carries width, height, and contentRect.
MSG_SETFOCUS 0x0007 Element received focus
MSG_KILLFOCUS 0x0008 Element lost focus
MSG_PAINT 0x000F Canvas container needs to be redrawn. Only dispatched to <canvas> elements — call wakaPAC.getDC(this.pacId) inside the handler to obtain the rendering context. For 2D canvases, triggered by wakaPAC.invalidateRect(); for WebGL canvases with renderLoop: true, fired every animation frame.
MSG_DPR_CHANGE 0x0010 Device pixel ratio changed (user moved the window to a display with a different DPI). wParam is the new ratio multiplied by 100 (e.g. 150 for 1.5×). Useful for rescaling canvas rendering.
MSG_KEYDOWN 0x0100 Key pressed down. wParam is the VK_* virtual key code. lParam carries modifier flags (KM_*). event.detail carries key (logical value) and code (physical identifier).
MSG_KEYUP 0x0101 Key released. Same wParam/lParam layout as MSG_KEYDOWN.
MSG_ACCEL 0x0112 Accelerator key combination matched a registered entry. wParam is the cmdId from the accelerator table. The originating MSG_KEYDOWN is suppressed and its browser default action is prevented. Register tables with wakaPAC.loadAcceleratorTable().
MSG_COMMAND 0x0111 A child component is notifying its parent that the user selected a command or a control event occurred.
MSG_TIMER 0x0113 Timer elapsed. wParam is the timer ID returned by wakaPAC.setTimer().
MSG_MOUSEMOVE 0x0200 Mouse moved. wParam is the modifier key bitmask (MK_*). lParam packs the container-relative coordinates: LOWORD = X, HIWORD = Y.
MSG_LBUTTONDOWN 0x0201 Left button pressed. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_LBUTTONUP 0x0202 Left button released. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_LBUTTONDBLCLK 0x0203 Left button double-clicked. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_RBUTTONDOWN 0x0204 Right button pressed. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_RBUTTONUP 0x0205 Right button released. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_MBUTTONDOWN 0x0207 Middle button pressed. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_MBUTTONUP 0x0208 Middle button released. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_MOUSEWHEEL 0x020A Mouse wheel scrolled. Use wakaPAC.GET_WHEEL_DELTA(wParam) to extract the delta (±120 per notch; positive = up). Use wakaPAC.GET_KEYSTATE(wParam) for modifier flags.
MSG_MOUSEENTER 0x020B Mouse entered the container. Not fired when crossing child-element boundaries — only on genuine entry from outside the container.
MSG_MOUSELEAVE 0x020C Mouse left the container. Not fired when crossing child-element boundaries — only on genuine exit from the container.
MSG_MOUSEENTER_DESCENDANT 0x020D Mouse entered an interactive descendant element (a, button, input, select, textarea, label, details, summary). event.detail.element is the element entered.
MSG_MOUSELEAVE_DESCENDANT 0x020E Mouse left an interactive descendant element. event.detail.element is the element left.
MSG_LCLICK 0x0210 Left-click completed (without drag). Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_MCLICK 0x0211 Middle-click completed. Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_RCLICK 0x0212 Right-click completed (without gesture). Same wParam/lParam layout as MSG_MOUSEMOVE.
MSG_CAPTURECHANGED 0x0215 Mouse capture was released from this container. Sent when wakaPAC.releaseCapture() is called. wParam and lParam are 0.
MSG_DRAGENTER 0x0231 A drag operation entered the container. Only fires once on genuine entry, not on child-boundary crossings. wParam is the modifier key bitmask (MK_*). lParam packs container-relative coordinates. event.detail.types lists the dragged data types.
MSG_DRAGOVER 0x0232 Drag is moving over a data-pac-drop-target element. Coalesced to one dispatch per animation frame per target change. event.detail.dropTarget is the element under the cursor; event.detail.types lists the data types.
MSG_DRAGLEAVE 0x0233 Drag left the container. Only fires once on genuine exit. event.detail.types lists the dragged data types.
MSG_DROP 0x0234 Item dropped onto a data-pac-drop-target element. event.detail carries dropTarget (the target element), text, html, uri, files (metadata array), and rawFiles (the live FileList).
MSG_GESTURE 0x0250 Mouse gesture recognized. event.detail.gesture is the pattern name (e.g. 'right', 'L'). event.detail.directions is the raw direction sequence. Register custom patterns with wakaPAC.registerGesture().
MSG_CHAR 0x0300 Printable character typed. wParam is the UTF-16 character code. Fires immediately after MSG_KEYDOWN for printable keys.
MSG_CHANGE 0x0301 Input value changed (change event)
MSG_SUBMIT 0x0302 Form submitted
MSG_INPUT 0x0303 Text field about to change (beforeinput — fires before the DOM mutation). wParam is the signed length delta: positive for insertions, negative for deletions, 0 for formatting changes.
MSG_INPUT_COMPLETE 0x0304 Text field changed (input — fires after the DOM mutation). Same wParam delta layout as MSG_INPUT.
MSG_COPY 0x0305 User initiated a copy operation. wParam is the modifier key bitmask (MK_*). lParam is the length of the selected text. event.detail.selectedText is the text being copied. Set event.detail.copyData to an object of MIME-type keys and string values to override what goes on the clipboard.
MSG_PASTE 0x0306 User initiated a paste operation. wParam is the modifier key bitmask (MK_*). lParam is the length of the plain-text payload. event.detail carries text/plain, text/html, text/rtf, uris, files (metadata), and types.
MSG_CONTEXTMENU 0x007B Right-click context menu or keyboard menu key. Call event.preventDefault() inside msgProc to suppress the native browser context menu.
MSG_FOREACH_REBUILT 0x0400 A foreach binding finished re-rendering its list. wParam is the number of rendered items. event.detail.arrayName is the foreach expression string; event.detail.marker is the value of data-pac-marker on the foreach element (or null if absent).
MSG_WEBGL_READY 0x0401 WebGL canvas is laid out and ready for use. Fired once per component lifetime after the first MSG_SIZE. event.detail.glContext is the WebGLRenderingContext or WebGL2RenderingContext. Use this message to compile shaders, upload geometry, and set up GL resources.
MSG_WEBGL_CONTEXT_LOST 0x0402 WebGL context was lost (GPU reset, tab backgrounded, etc.). All GL objects (buffers, textures, programs) are now invalid and must not be used. Null out all GL handles in this handler and wait for MSG_WEBGL_CONTEXT_RESTORED.
MSG_WEBGL_CONTEXT_RESTORED 0x0403 WebGL context has been recreated by the browser. Rebuild all GL resources from scratch. event.detail.glContext is the fresh context.
MSG_USER 0x1000 Base value for custom user-defined messages. Use MSG_USER + 1, MSG_USER + 2, etc. for application-specific messages sent via wakaPAC.sendMessage().
MSG_PLUGIN 0x2000 Base value for plugin-defined messages. Plugins should use MSG_PLUGIN + N for their own message types to avoid colliding with application messages in the MSG_USER range.

Keyboard Event Types

WakaPAC provides different keyboard event types for different purposes:

Event When Fires wParam lParam Best For
MSG_KEYDOWN Key pressed down VK code Modifier keys (KM_*) Keyboard shortcuts, game controls, navigation
MSG_KEYUP Key released VK code Modifier keys (KM_*) Detecting key release, toggle states
MSG_CHAR Printable character typed Character code (UTF-16) Unused (0) Character filtering, custom input handling
MSG_INPUT Text field changed Length of inserted/changed text Unused (0) Validation, paste/autocomplete detection

Modifier Key Constants

Mouse Event Modifiers (MK_*)

Used in wParam for mouse events. Use bitwise AND to check which modifiers are held:

Constant Hex Value Description
MK_LBUTTON 0x0001 Left mouse button is down
MK_RBUTTON 0x0002 Right mouse button is down
MK_SHIFT 0x0004 Shift key is down
MK_CONTROL 0x0008 Ctrl key is down
MK_MBUTTON 0x0010 Middle mouse button is down
MK_XBUTTON1 0x0020 First extra mouse button (browser back)
MK_XBUTTON2 0x0040 First extra mouse button (browser back)
MK_ALT 0x0080 Alt key is down
MK_META 0x0100 Meta/Windows key

Keyboard Event Modifiers (KM_*)

Used in lParam for keyboard events. Use bitwise AND to check which modifiers are held:

Constant Hex Value Description
KM_SHIFT 0x02000000 Shift key is down
KM_CONTROL 0x04000000 Ctrl key is down
KM_META 0x08000000 Meta/Windows key is down
KM_ALT 0x20000000 Alt key is down

Virtual Key (VK) Codes

Complete reference of Win32 Virtual Key codes exported by WakaPAC. All codes are available as wakaPAC.VK_* constants.

Control Keys

Constant Hex Value Key
VK_BACK 0x08 Backspace
VK_TAB 0x09 Tab
VK_RETURN 0x0D Enter
VK_SHIFT 0x10 Shift
VK_CONTROL 0x11 Ctrl
VK_MENU 0x12 Alt
VK_PAUSE 0x13 Pause
VK_CAPITAL 0x14 Caps Lock
VK_ESCAPE 0x1B Esc
VK_SPACE 0x20 Space

Navigation Keys

Constant Hex Value Key
VK_PRIOR 0x21 Page Up
VK_NEXT 0x22 Page Down
VK_END 0x23 End
VK_HOME 0x24 Home
VK_LEFT 0x25 Left Arrow
VK_UP 0x26 Up Arrow
VK_RIGHT 0x27 Right Arrow
VK_DOWN 0x28 Down Arrow

Editing Keys

Constant Hex Value Key
VK_INSERT 0x2D Insert
VK_DELETE 0x2E Delete

Number Keys (Top Row)

Constant Hex Value Key
VK_0 - VK_9 0x30 - 0x39 0 through 9

Letter Keys

Constant Hex Value Key
VK_A - VK_Z 0x41 - 0x5A A through Z

Windows Keys

Constant Hex Value Key
VK_LWIN 0x5B Left Windows key
VK_RWIN 0x5C Right Windows key
VK_APPS 0x5D Applications key (context menu)

Numpad Keys

Constant Hex Value Key
VK_NUMPAD0 - VK_NUMPAD9 0x60 - 0x69 Numpad 0 through 9
VK_MULTIPLY 0x6A Numpad *
VK_ADD 0x6B Numpad +
VK_SEPARATOR 0x6C Numpad separator
VK_SUBTRACT 0x6D Numpad -
VK_DECIMAL 0x6E Numpad .
VK_DIVIDE 0x6F Numpad /

Function Keys

Constant Hex Value Key
VK_F1 - VK_F12 0x70 - 0x7B F1 through F12

Lock Keys

Constant Hex Value Key
VK_NUMLOCK 0x90 Num Lock
VK_SCROLL 0x91 Scroll Lock

Shift Variants

Constant Hex Value Key
VK_LSHIFT 0xA0 Left Shift
VK_RSHIFT 0xA1 Right Shift
VK_LCONTROL 0xA2 Left Ctrl
VK_RCONTROL 0xA3 Right Ctrl
VK_LMENU 0xA4 Left Alt
VK_RMENU 0xA5 Right Alt

Browser Keys

Constant Hex Value Key
VK_BROWSER_BACK 0xA6 Browser Back
VK_BROWSER_FORWARD 0xA7 Browser Forward
VK_BROWSER_REFRESH 0xA8 Browser Refresh
VK_BROWSER_STOP 0xA9 Browser Stop
VK_BROWSER_SEARCH 0xAA Browser Search
VK_BROWSER_FAVORITES 0xAB Browser Favorites
VK_BROWSER_HOME 0xAC Browser Home

Media Keys

Constant Hex Value Key
VK_VOLUME_MUTE 0xAD Volume Mute
VK_VOLUME_DOWN 0xAE Volume Down
VK_VOLUME_UP 0xAF Volume Up
VK_MEDIA_NEXT_TRACK 0xB0 Next Track
VK_MEDIA_PREV_TRACK 0xB1 Previous Track
VK_MEDIA_STOP 0xB2 Stop Media
VK_MEDIA_PLAY_PAUSE 0xB3 Play/Pause Media

Punctuation Keys

Constant Hex Value Key
VK_OEM_1 0xBA ; :
VK_OEM_PLUS 0xBB = +
VK_OEM_COMMA 0xBC , <
VK_OEM_MINUS 0xBD - _
VK_OEM_PERIOD 0xBE . >
VK_OEM_2 0xBF / ?
VK_OEM_3 0xC0 ` ~
VK_OEM_4 0xDB [ {
VK_OEM_5 0xDC \ |
VK_OEM_6 0xDD ] }
VK_OEM_7 0xDE ' "

Built-in Gesture Patterns

Pattern Name Directions Description Common Use
'right' R Drag right Forward navigation, next item
'left' L Drag left Back navigation, previous item
'up' U Drag up Scroll to top, collapse
'down' D Drag down Scroll to bottom, expand
'L' D, R Down then right (L-shape) New tab, new item
'inverted-L' D, L Down then left (inverted L) Close tab, delete item

Timer API Reference

Function Parameters Returns Description
wakaPAC.setTimer(pacId, elapse) pacId: Component ID
elapse: Interval in ms
number (timer ID) Creates a timer that fires every elapse milliseconds. Returns auto-generated timer ID.
wakaPAC.killTimer(pacId, timerId) pacId: Component ID
timerId: Timer to stop
boolean Stops a specific timer. Returns true if timer was found and killed.
wakaPAC.killAllTimers(pacId) pacId: Component ID number Stops all timers for a component. Returns number of timers killed.

Coordinate Conversion Functions

Function Parameters Returns Description
this.containerToViewport(x, y) x: Container X
y: Container Y
{x, y} Converts container-relative to viewport-absolute coordinates
this.viewportToContainer(x, y) x: Viewport X
y: Viewport Y
{x, y} Converts viewport-absolute to container-relative coordinates
wakaPAC.LOWORD(lParam) lParam: Packed value number Extracts low 16 bits (X coordinate)
wakaPAC.HIWORD(lParam) lParam: Packed value number Extracts high 16 bits (Y coordinate)
wakaPAC.MAKEPOINTS(lParam) lParam: Packed value {x, y} Extracts both coordinates at once
wakaPAC.GET_WHEEL_DELTA(wParam) wParam: Mouse wheel wParam number Extracts wheel delta from wParam (±120 per notch, normalized). Positive = scroll up, negative = scroll down
wakaPAC.GET_KEYSTATE(wParam) wParam: Mouse wheel wParam number Extracts modifier key flags from wParam (MK_SHIFT, MK_CONTROL, MK_ALT)