Skip to content

Instantly share code, notes, and snippets.

@avrahamappel
Created March 20, 2026 14:47
Show Gist options
  • Select an option

  • Save avrahamappel/ef1c2dc0feed4af51e324800cdc626cf to your computer and use it in GitHub Desktop.

Select an option

Save avrahamappel/ef1c2dc0feed4af51e324800cdc626cf to your computer and use it in GitHub Desktop.
mapkey('P', '#1Paste from clipboard', function() {
// Grab the latest clipboard entry
const clipboardText = Clipboard.get();
// Get all input elements on the page
const inputs = $$('input, textarea');
// Check how many inputs there are
if (inputs.length === 0) {
alert("No input fields found.");
return;
}
// Create an array of hints
const hints = inputs.map((input, index) => ({
hint: String(index + 1),
element: input
}));
// If there is only one input, fill it automatically
if (hints.length === 1) {
hints[0].element.value = clipboardText;
return;
}
// Show hints
Hints.create(hints, function(hint) {
hint.element.value = clipboardText;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment