import "@hotwired/turbo-rails"
import "controllers"
import "lexxy"

// Bind ctrl + s to submit form
document.addEventListener("keydown", function (event) {
  // Check if Ctrl key is pressed and the pressed key is 'S'
  if ((event.ctrlKey || event.metaKey) && event.key === "s") {
    // Prevent the browser's default save action
    event.preventDefault();

    // Submit the form
    const form = document.querySelector(".has--key-ctrls");
    if (form) {
      form.requestSubmit();
    }
  }
});
