MouseEvent.mozInputSource is a non-standard read-only number that reports the kind of input device that created the mouse event. Learn the MOZ_SOURCE_* values, why device type matters for accuracy, how to feature-detect safely, and how Pointer Events replace it.
01
Kind
Instance property
02
Returns
Number (0–6)
03
Status
Non-standard
04
Access
event.mozInputSource
05
Engine
Firefox-oriented
06
Prefer
pointerType
Fundamentals
Introduction
Not every “mouse” event comes from a physical mouse. Touch screens, pens, and even keyboards can produce mouse-like events. Firefox exposes mozInputSource so you can tell which device was involved—handy when touch coordinates need larger hit targets than a precise mouse.
JavaScript
element.addEventListener("mousedown", (event) => {
console.log(event.mozInputSource); // number in Firefox; often undefined elsewhere
});
💡
Beginner tip
Treat mozInputSource as Firefox legacy reading material. For new code, listen to pointerdown / pointermove and read event.pointerType instead.
Concept
Understanding the Property
MDN: MouseEvent.mozInputSource provides information indicating the type of device that generated the event. That lets you, for example, decide whether coordinates came from an actual mouse or from a touch event (which can affect how accurately you interpret those coordinates).
Instance — read event.mozInputSource in a handler.
Number — one of the MOZ_SOURCE_* values (0–6).
Non-standard — not in any official specification.
Firefox-first — usually missing in Chromium and Safari.
Foundation
📝 Syntax
JavaScript
const source = mouseEvent.mozInputSource;
Value
A number describing the input device when the property is supported; otherwise the property is typically undefined.
Safe read with fallback
JavaScript
function getInputKind(event) {
if (typeof event.mozInputSource === "number") {
return event.mozInputSource; // Firefox / non-standard
}
if (typeof event.pointerType === "string" && event.pointerType) {
return event.pointerType; // standard Pointer Events
}
return "unknown";
}
Reference
📚 MOZ_SOURCE_* Values
MDN documents these constants and numeric values. In Firefox they may also appear as MouseEvent.MOZ_SOURCE_MOUSE, MouseEvent.MOZ_SOURCE_TOUCH, and so on.
Constant
Value
Meaning
MOZ_SOURCE_UNKNOWN
0
Input device is unknown
MOZ_SOURCE_MOUSE
1
Mouse or mouse-like device
MOZ_SOURCE_PEN
2
Pen on a tablet
MOZ_SOURCE_ERASER
3
Eraser on a tablet
MOZ_SOURCE_CURSOR
4
Cursor-generated event
MOZ_SOURCE_TOUCH
5
Touch interface
MOZ_SOURCE_KEYBOARD
6
Keyboard-generated event
Compare
⚖️ mozInputSource vs pointerType
API
Status
Typical values
event.mozInputSource
Non-standard
Numbers 0–6 (Firefox)
event.pointerType
Standard
"mouse", "pen", "touch"
Use Pointer Events for new apps. Keep mozInputSource only when you must understand or maintain older Firefox-specific code.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Read (if present)
event.mozInputSource
Feature-detect
typeof event.mozInputSource === "number"
Compare to mouse
event.mozInputSource === 1 (or MOZ_SOURCE_MOUSE)
Compare to touch
event.mozInputSource === 5 (or MOZ_SOURCE_TOUCH)
Modern alternative
event.pointerType on PointerEvent
MDN status
Non-standard (not in any spec)
Snapshot
🔍 At a Glance
Four facts about mozInputSource.
Kind
instance
On the event
Type
number
0–6 when set
Status
non-std
Not in any spec
Prefer
pointerType
Pointer Events
Hands-On
Examples Gallery
Examples follow MDN MouseEvent.mozInputSource. Best results are in Firefox. Other browsers usually show undefined—that is expected for a non-standard API.
MouseEvent.mozInputSource is a Non-standard Mozilla property. Logos use the shared browser-image-sprite.png sprite from this project. Expect Firefox-oriented support; do not require it for production UX.
✓ Non-standard · Firefox-oriented
MouseEvent.mozInputSource
Firefox input-device code. Feature-detect; prefer PointerEvent.pointerType for new apps.
LimitedNon-standard
Google ChromeNot supported (property usually undefined)
No support
Mozilla FirefoxSupported · Non-standard Gecko property
Supported
Apple SafariNot supported (property usually undefined)
No support
Microsoft EdgeNot supported (Chromium)
No support
OperaNot supported (Chromium)
No support
Internet ExplorerNot a modern target for this API
No support
mozInputSourceLimited
Bottom line: Non-standard device-source number; use pointerType for cross-browser input detection.
Wrap Up
Conclusion
event.mozInputSource is a non-standard Firefox number that names the device behind a mouse event—mouse, pen, touch, keyboard, and more. Learn it for legacy Gecko code, then ship with PointerEvent.pointerType instead.
It is a non-standard, read-only number on MouseEvent (mainly Firefox) that describes which kind of device generated the event—for example a real mouse, a tablet pen, a touch screen, or a keyboard.
MDN marks it Non-standard — not part of any specification. It is not labeled Deprecated or Experimental on that MDN page, but you should not rely on it in production cross-browser code.
MDN lists: 0 unknown, 1 mouse, 2 pen, 3 eraser, 4 cursor, 5 touch, 6 keyboard. In Firefox these match MouseEvent.MOZ_SOURCE_* constants when available.
Prefer the standard Pointer Events API: PointerEvent.pointerType returns "mouse", "pen", or "touch". It works across modern browsers and is the supported way to tell devices apart.
Touch and pen coordinates can be less precise than a mouse. Knowing the device helps you adjust hit targets, ignore hover-only UI on touch, or change accuracy assumptions.
No. It is a Mozilla-specific extension. In Chrome, Safari, and Edge the property is usually undefined. Always feature-detect before reading it.
Did you know?
MDN highlights a practical reason this property existed: touch-generated mouse events can be less precise than real mouse events. Knowing the source helped Firefox apps adjust how they trusted coordinates—today that job belongs to PointerEvent.pointerType across browsers.