Event Modifiers

Modifiers change how events behave or when they fire.

Core modifiers

  • preventevent.preventDefault()
  • stopevent.stopPropagation()
  • once → handler runs once
  • passive → passive listener
  • outside → fires when click happens outside the element
  • self → only fires when event target is the element

Example

behavior .dialog {
  on click.outside.prevent() { open = false; }
}

Key modifiers

behavior .field {
  on keyup.enter() { submit(); }
  on keydown.shift.enter() { submit(); }
}

Ordering

Modifiers apply in the order they appear, but the end result matches the list above.