Copy and paste does not work well on Proxmox KVM on the UI.
You can try to connect using a serial port to enable copy and paste over the UI.
Using a Script
We created a script to simulate keyboard typing and paste data over KVM when using the UI.
Open your Chrome Dev Tools, and paste this.
function simulateKeyEvent(el, eventType, key, options = {}) {
const evt = new KeyboardEvent(eventType, { key, ...options });
el.dispatchEvent(evt);
}
const sendKey = (char) => {
let capsLockOn = false;
const SHIFT_NEEDED = /[A-Z!@#$%^&*()_+{}:"<>?~|]/;
const canvas = document.querySelector("canvas");
canvas.focus();
if (char === '\n') {
simulateKeyEvent(canvas, "keydown", "Enter");
simulateKeyEvent(canvas, "keyup", "Enter");
} else {
const needsShift = SHIFT_NEEDED.test(char);
const isUpperCase = char >= 'A' && char <= 'Z';
if (needsShift) {
simulateKeyEvent(canvas, "keydown", "Shift", { keyCode: 16 });
}
if (isUpperCase && capsLockOn) {
simulateKeyEvent(canvas, "keydown", char.toLowerCase());
simulateKeyEvent(canvas, "keyup", char.toLowerCase());
} else {
simulateKeyEvent(canvas, "keydown", char);
simulateKeyEvent(canvas, "keyup", char);
}
if (needsShift) {
simulateKeyEvent(canvas, "keyup", "Shift", { keyCode: 16 });
}
if (char === "CapsLock") {
capsLockOn = !capsLockOn;
console.log("Caps Lock state changed:", capsLockOn);
}
}
};
function cp(text) {
let index = 0;
function typeChar() {
if (index < text.length) {
sendKey(text[index]);
index++;
setTimeout(typeChar, 100); // Adjust delay as needed
}
}
typeChar();
}
To paste something, you first need to focus on the UI, and then type cp('mydata')
You can use this when you don't have access to the VM over SSH.
In Summary
If you are creative enough, you can solve these limitations.
Woovi
Woovi is a fintech platform revolutionizing how businesses and developers handle payments in Brazil. Built with a developer-first mindset, Woovi simplifies integration with instant payment methods like Pix, enabling companies to receive payments seamlessly and automate financial workflows.
If you want to work with us, we are hiring!
Top comments (0)