refactor(front-end): add all the key combinations specified in the specs

main
Josue 3 years ago
parent 5ff48dad9b
commit 83883821f4
  1. 19
      striker-ui/components/Display/FullSize.tsx
  2. 35
      striker-ui/components/Display/keyCombinations.ts

@ -73,9 +73,20 @@ const FullSize = ({ setMode }: PreviewProps): JSX.Element => {
setAnchorEl(event.currentTarget);
};
const handleSendKeys = () => {
const handleSendKeys = (scans: string[]) => {
if (rfb.current) {
rfb.current.sendCtrlAltDel();
if (!scans.length) rfb.current.sendCtrlAltDel();
else {
// Send pressing keys
scans.forEach((scan) => {
rfb.current.sendKey(scan, 1);
});
// Send releasing keys in reverse order
for (let i = scans.length - 1; i >= 0; i -= 1) {
rfb.current.sendKey(scans[i], 0);
}
}
setAnchorEl(null);
}
};
@ -118,10 +129,10 @@ const FullSize = ({ setMode }: PreviewProps): JSX.Element => {
open={Boolean(anchorEl)}
onClose={() => setAnchorEl(null)}
>
{keyCombinations.map(({ keys }) => {
{keyCombinations.map(({ keys, scans }) => {
return (
<MenuItem
onClick={handleSendKeys}
onClick={() => handleSendKeys(scans)}
className={classes.keysItem}
key={keys}
>

@ -1,14 +1,27 @@
const keyCombinations: Array<{ keys: string; scans: string }> = [
{ keys: 'Ctrl + Alt + Del', scans: 'Optimal' },
{ keys: 'Ctrl + Alt + F1', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F2', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F3', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F4', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F5', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F6', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F7', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F8', scans: 'Not Ready' },
{ keys: 'Ctrl + Alt + F9', scans: 'Not Ready' },
const ControlL = '0xffe3';
const AltL = '0xffe9';
const F1 = '0xffbe';
const F2 = '0xffbf';
const F3 = '0xffc0';
const F4 = '0xffc1';
const F5 = '0xffc2';
const F6 = '0xffc3';
const F7 = '0xffc4';
const F8 = '0xffc5';
const F9 = '0xffc6';
const keyCombinations: Array<{ keys: string; scans: string[] }> = [
{ keys: 'Ctrl + Alt + Delete', scans: [] },
{ keys: 'Ctrl + Alt + F1', scans: [ControlL, AltL, F1] },
{ keys: 'Ctrl + Alt + F2', scans: [ControlL, AltL, F2] },
{ keys: 'Ctrl + Alt + F3', scans: [ControlL, AltL, F3] },
{ keys: 'Ctrl + Alt + F4', scans: [ControlL, AltL, F4] },
{ keys: 'Ctrl + Alt + F5', scans: [ControlL, AltL, F5] },
{ keys: 'Ctrl + Alt + F6', scans: [ControlL, AltL, F6] },
{ keys: 'Ctrl + Alt + F7', scans: [ControlL, AltL, F7] },
{ keys: 'Ctrl + Alt + F8', scans: [ControlL, AltL, F8] },
{ keys: 'Ctrl + Alt + F9', scans: [ControlL, AltL, F9] },
];
export default keyCombinations;

Loading…
Cancel
Save