You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hello, I have a number of required key combinations that use the same key twice.
For example, ["d d"]. The first time I click "d d". It functions as expected. However when I hit "d" a single time after that it fires the ["d d"] combination. I believe it is storing the 2nd d somewhere so when a single "d" is pressed it fires the combination. Does anyone have any ideas on how to clear this memory? Or another solution.
`import { EditorCellType } from "../types";
import { CellType } from "@nteract/commutable";
import { ICellProps } from "./ConnectedCell";
/**
todo
*/
export const keyMap = {
CHANGE_CELL_TYPE_TO_MARKDOWN: ["m"],
CHANGE_CELL_TYPE_TO_CODE: ["y"],
PASTE_CELL_BELOW: ["v"],
COPY_CELL: ["c"],
CUT_CELL: ["x"],
INSERT_ABOVE: ["a"],
INSERT_BELOW: ["b"],
DELETE_CELL: ["d d"],
INTERRUPT_KERNEL: ["i", "i"], // should be i i
RESTART_KERNEL: ["0", "0"], // should be 0 0
FOCUS_EDITOR: ["enter"],
UNFOCUS_EDITOR: ["escape"],
EXECUTE_CELL: ["control+enter"],
FOCUS_ABOVE: ["up", "k"],
FOCUS_BELOW: ["down", "j"],
EXECUTE_CELL_INSERT_BELOW: ["alt+enter"],
TOGGLE_OUTPUT: ["o"],
TOGGLE_LINE_NUMBERS: ["l"],
TOGGLE_OUTPUT_SCROLLING: ["shift+o"],
SCROLL_DOWN: ["space"],
SCROLL_UP: ["shift+space"],
SAVE_NOTEBOOK: ["s"]
};
Describe the bug
Hello, I have a number of required key combinations that use the same key twice.
For example, ["d d"]. The first time I click "d d". It functions as expected. However when I hit "d" a single time after that it fires the ["d d"] combination. I believe it is storing the 2nd d somewhere so when a single "d" is pressed it fires the combination. Does anyone have any ideas on how to clear this memory? Or another solution.
`import { EditorCellType } from "../types";
import { CellType } from "@nteract/commutable";
import { ICellProps } from "./ConnectedCell";
/**
*/
export const keyMap = {
CHANGE_CELL_TYPE_TO_MARKDOWN: ["m"],
CHANGE_CELL_TYPE_TO_CODE: ["y"],
PASTE_CELL_BELOW: ["v"],
COPY_CELL: ["c"],
CUT_CELL: ["x"],
INSERT_ABOVE: ["a"],
INSERT_BELOW: ["b"],
DELETE_CELL: ["d d"],
INTERRUPT_KERNEL: ["i", "i"], // should be i i
RESTART_KERNEL: ["0", "0"], // should be 0 0
FOCUS_EDITOR: ["enter"],
UNFOCUS_EDITOR: ["escape"],
EXECUTE_CELL: ["control+enter"],
FOCUS_ABOVE: ["up", "k"],
FOCUS_BELOW: ["down", "j"],
EXECUTE_CELL_INSERT_BELOW: ["alt+enter"],
TOGGLE_OUTPUT: ["o"],
TOGGLE_LINE_NUMBERS: ["l"],
TOGGLE_OUTPUT_SCROLLING: ["shift+o"],
SCROLL_DOWN: ["space"],
SCROLL_UP: ["shift+space"],
SAVE_NOTEBOOK: ["s"]
};
/**
*/
export function getHandlers(props: any) {
return {
TOGGLE_OUTPUT_SCROLLING: () => onKeyToggleOutputScrolling(props),
CHANGE_CELL_TYPE_TO_CODE: () => onKeyChangeCellTypeToCode(props),
CHANGE_CELL_TYPE_TO_MARKDOWN: () => onKeyChangeCellTypeToMarkdown(props),
COPY_CELL: () => onKeyCopyCell(props),
PASTE_CELL_BELOW: () => onKeyPasteCellBelow(props),
CUT_CELL: () => onKeyCutCell(props),
INSERT_ABOVE: () => onKeyInsertCellAbove(props),
INSERT_BELOW: () => onKeyInsertCellBelow(props),
DELETE_CELL: () => onKeyDeleteCell(props),
INTERRUPT_KERNEL: () => onKeyInterruptKernel(props),
RESTART_KERNEL: () => onKeyRestartKernel(props),
EXECUTE_CELL: () => onKeyExecuteCell(props),
EXECUTE_CELL_INSERT_BELOW: () => onKeyExecuteCellThenInsertCellBelow(props),
FOCUS_EDITOR: () => onKeyFocusEditor(props),
FOCUS_ABOVE: () => onKeyFocusAbove(props),
FOCUS_BELOW: () => onKeyFocusBelow(props),
TOGGLE_OUTPUT: () => onKeyToggleCellOutputVisibility(props),
SAVE_NOTEBOOK: (e: KeyboardEvent) => onKeySaveNotebook(e, props)
};
}
function onKeySaveNotebook(e: KeyboardEvent, props: ICellProps) {
e.preventDefault();
props.saveNotebook();
}
function onKeyToggleCellOutputVisibility(props: ICellProps) {
props.toggleCellOutputVisibility();
}
function onKeyRestartKernel(props: ICellProps) {
if (!props.settings.readOnly) {
props.restartKernel();
}
}
function onKeyDeleteCell(props: ICellProps) {
props.deleteCell();
}
function onKeyInterruptKernel(props: ICellProps) {
props.interruptKernel();
}
function onKeyChangeCellTypeToCode(props: ICellProps) {
const cellType: CellType = props.settings.cellType;
if (cellType !== EditorCellType.code) {
props.changeCellType(EditorCellType.code);
}
}
function onKeyChangeCellTypeToMarkdown(props: ICellProps) {
const cellType: CellType = props.settings.cellType;
if (cellType !== EditorCellType.markdown) {
props.changeCellType(EditorCellType.markdown);
}
}
function onKeyInsertCellBelow(props: any) {
const cellType: CellType = props.cellType;
const contentRef: string = props.contentRef;
props.insertCellBelow(contentRef, cellType);
}
function onKeyInsertCellAbove(props: any) {
const cellType: CellType = props.cellType;
const contentRef: string = props.contentRef;
props.insertCellAbove(contentRef, cellType);
}
function onKeyCopyCell(props: ICellProps) {
props.copyCell();
}
function onKeyPasteCellBelow(props: ICellProps) {
props.pasteCellBelow();
}
function onKeyCutCell(props: ICellProps) {
props.cutCell();
}
function onKeyToggleOutputScrolling(props: ICellProps) {
props.toggleOutputExpansion();
}
function onKeyFocusBelow(props: any) {
props.focusBelowCell();
}
function onKeyFocusAbove(props: any) {
props.focusAboveCell();
}
function onKeyExecuteCell(props: ICellProps) {
// tslint:disable no-console
console.log('rowboat');
props.executeCell();
}
function onKeyExecuteCellThenInsertCellBelow(props: any) {
const cellType: CellType = props.cellType;
const contentRef: string = props.contentRef;
props.executeCell();
props.insertCellBelow(contentRef, cellType);
}
function onKeyFocusEditor(props: ICellProps) {
props.focusEditor();
}
`
Expected behavior
I am expecting the key combination to only fire when "d" and then "d" is pressed even after using "d d" once.
Platform (please complete the following information):
The text was updated successfully, but these errors were encountered: