1import { Controller } from "@hotwired/stimulus" 2 3// Global controller attached to <body> that submits the closest form 4// when Cmd+Enter (Mac) or Ctrl+Enter (other) is pressed inside any 5// <input> or <textarea>. 6export default class extends Controller { 7 handleKeydown = (event) => { 8 if (!(event.metaKey || event.ctrlKey) || event.key !== "Enter") return 9 10 const target = event.target 11 if (target.tagName !== "INPUT" && target.tagName !== "TEXTAREA" && !target.hasAttribute("contenteditable")) return 12 13 const form = target.closest("form") 14 if (!form) return 15 16 event.preventDefault() 17 form.requestSubmit() 18 } 19 20 connect() { 21 this.element.addEventListener("keydown", this.handleKeydown) 22 } 23 24 disconnect() { 25 this.element.removeEventListener("keydown", this.handleKeydown) 26 } 27}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.