-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKLITEHotkeysMod.js
More file actions
95 lines (84 loc) · 2.96 KB
/
Copy pathKLITEHotkeysMod.js
File metadata and controls
95 lines (84 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// =============================================
// KLITE Hotkeys Mod
// Copyrights Peter Hauer
// under GPL-3.0 license
// see https://github.com/PeterPeet/
// =============================================
// Hotkeys Mod for KoboldAI Lite v1.0
// Ctrl+Shift+Enter = Generate/Submit
// Ctrl+Shift+R = Retry
// Ctrl+Shift+Z = Undo/Back
// Ctrl+Shift+Y = Redo
document.addEventListener('keydown', function(event) {
// Check if we're not in an input field (to avoid interfering with normal typing)
const isInInput = event.target.tagName === 'INPUT' ||
event.target.tagName === 'TEXTAREA' ||
event.target.contentEditable === 'true';
// Ctrl+Shift+Enter for Generate/Submit
if (event.ctrlKey && event.shiftKey && event.key === 'Enter') {
event.preventDefault();
// Check if generate button is available and not disabled
const generateBtn = document.getElementById('btnsend');
if (generateBtn && !generateBtn.disabled) {
prepare_submit_generation();
}
return;
}
// Ctrl+Shift+R for Retry
if (event.ctrlKey && event.shiftKey && event.key === 'R') {
event.preventDefault();
btn_retry();
return;
}
// Ctrl+Shift+Z for Undo/Back
if (event.ctrlKey && event.shiftKey && event.key === 'Z') {
event.preventDefault();
btn_back();
return;
}
// Ctrl+Shift+Y for Redo
if (event.ctrlKey && event.shiftKey && event.key === 'Y') {
event.preventDefault();
btn_redo();
return;
}
// Ctrl+Shift+A for Abort Generation
if (event.ctrlKey && event.shiftKey && event.key === 'A') {
event.preventDefault();
abort_generation();
return;
}
});
// Show a notification that hotkeys are active
console.log('🔥 Hotkeys Mod Loaded!');
console.log('Hotkeys:');
console.log(' Ctrl+Shift+Enter = Generate/Submit');
console.log(' Ctrl+Shift+R = Retry');
console.log(' Ctrl+Shift+Z = Undo/Back');
console.log(' Ctrl+Shift+Y = Redo');
console.log(' Ctrl+Shift+A = Abort Generation');
// Show a brief notification in the UI
if (typeof msgbox === 'function') {
setTimeout(() => {
const notification = document.createElement('div');
notification.innerHTML = '🔥 Hotkeys Mod Active!<br>Ctrl+Shift+Enter=Generate, Ctrl+Shift+R=Retry';
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background: #333;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 10000;
font-size: 12px;
box-shadow: 0 2px 10px rgba(0,0,0,0.3);
`;
document.body.appendChild(notification);
setTimeout(() => {
if (notification.parentNode) {
notification.parentNode.removeChild(notification);
}
}, 5000);
}, 1000);
};