Skip to content

Commit

Permalink
fix: update LLM shortcuts to work on Macs better (#458)
Browse files Browse the repository at this point in the history
fixes #457
  • Loading branch information
ellvix authored Apr 2, 2024
1 parent 9d91a88 commit d0f697d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
31 changes: 27 additions & 4 deletions src/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,20 @@ class Menu {
<td>Auto-play speed down</td>
<td>Comma</td>
</tr>
<tr>
<td>Open GenAI Chat</td>
<td>${
constants.control
} + Shift + ?</td>
</tr>
<tr>
<td>Copy last chat message</td>
<td>${constants.alt} + Shift + C</td>
</tr>
<tr>
<td>Copy full chat history</td>
<td>${constants.alt} + Shift + A</td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -1015,7 +1029,12 @@ class ChatLLM {
document,
'keyup',
function (e) {
if (e.key == '?' && (e.ctrlKey || e.metaKey) || e.key == '¿') {
if (
((e.ctrlKey || e.metaKey) &&
e.shiftKey &&
(e.key == '?' || e.key == '¿')) ||
(e.metaKey && e.altKey && (e.key == '?' || e.key == '¿'))
) {
chatLLM.Toggle();
}
},
Expand Down Expand Up @@ -1133,8 +1152,8 @@ class ChatLLM {
text = e.target.closest('p').previousElementSibling.innerHTML;
}
} else if (e.type == 'keyup') {
// check for alt shift c
if (e.key == 'C' && (e.ctrlKey || e.metaKey) && e.shiftKey) {
// check for alt shift c or ctrl shift c
if (e.key == 'C' && (e.ctrlKey || e.metaKey || e.altKey) && e.shiftKey) {
e.preventDefault();
// get the last message
let elem = document.querySelector(
Expand All @@ -1143,7 +1162,11 @@ class ChatLLM {
if (elem) {
text = elem.innerHTML;
}
} else if (e.key == 'A' && (e.ctrlKey || e.metaKey) && e.shiftKey) {
} else if (
e.key == 'A' &&
(e.ctrlKey || e.metaKey || e.altKey) &&
e.shiftKey
) {
e.preventDefault();
// get html of the full chat history
text = document.getElementById('chatLLM_chat_history').innerHTML;
Expand Down
6 changes: 2 additions & 4 deletions src/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ class Control {
if (e.key == 'x') {
// X: x label
let xlabel = '';
if (constants.chartType == 'bar' ||
singleMaidr.type == 'line') {
if (constants.chartType == 'bar' || singleMaidr.type == 'line') {
xlabel = plot.plotLegend.x;
} else if (
constants.chartType == 'heat' ||
Expand All @@ -219,8 +218,7 @@ class Control {
} else if (e.key == 'y') {
// Y: y label
let ylabel = '';
if (constants.chartType == 'bar' ||
singleMaidr.type == 'line') {
if (constants.chartType == 'bar' || singleMaidr.type == 'line') {
ylabel = plot.plotLegend.y;
} else if (
constants.chartType == 'heat' ||
Expand Down

0 comments on commit d0f697d

Please sign in to comment.