CKTIS / JavaScript
Clipboard.writeText — writing text to the clipboard
Clipboard.writeText writes plain text to the system clipboard. The operation is asynchronous and requires a secure context and browser permission to write.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
await navigator.clipboard.writeText(text);Clipboard.writeText, called as navigator.clipboard.writeText(text), replaces clipboard contents with plain text, not HTML. It returns a Promise that fulfills with undefined after writing.
A secure context and a focused, active document are required. Call directly from a click; user activation does not guarantee permission. Denial can reject the promise with NotAllowedError.
Use await and try...catch; report success only after fulfillment. Check API availability in the target browser: Node 24 in the repository does not establish browser support.
Examples
const button = document.createElement('button');
button.type = 'button';
button.textContent = 'Copy CKTIS';
const status = document.createElement('p');
status.setAttribute('role', 'status');
document.body.append(button, status);
button.addEventListener('click', async () => {
if (!window.isSecureContext ||
typeof navigator.clipboard?.writeText !== 'function') {
status.textContent = 'Unavailable';
return;
}
try {
await navigator.clipboard.writeText('CKTIS');
status.textContent = 'Copied: CKTIS';
} catch (error) {
status.textContent = `Copy failed: ${error.name}`;
}
});Result
Copied: CKTIS
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.