Key Bindings

Configuring Key Bindings

You can update the default key bindings (keyboard shortcuts) by the keymap option:

new RyuseiCode( {
keymap: {
selectAll: [ 'A', true ],
},
} );
JavaScript

The value is a KeyMatcher tuple as [ string, boolean?, boolean?, boolean? ] corresponding with [ key, ctrl, shift, alt ] in Windows and [ key, ⌘, ⇧, ⌥ ] in Mac.

For example, [ 'Z', true, true ] matches Ctrl+Shift+Z and ++Z.

To assign multiple shortcuts to a single action if necessary, pass an array with KeyMatcher tuples:

{
selectAll: [ [ 'A', true ], [ 'B', true ] ],
}
JavaScript

Passing null or false to the action disables the shortcut:

{
selectAll: false,
}
JavaScript
Disabling specific shortcuts does not mean it prevents the native behavior, but only deactivates RyuseiCode key bindings.

Default Key Bindings

Main

{
selectAll: [ 'A', true ],
}
JavaScript
{
search : [ 'F', true ],
searchNext: [ 'F3' ],
searchPrev: [ 'F3', false, true ],
replace : [ 'F', true, true ],
}
JavaScript

Comment

{
lineComment : [ '/', true ],
blockComment: [ '?', true, true ],
}
JavaScript

History

{
undo: [ 'Z', true, false ],
redo: [ 'Z', true, true ],
}
JavaScript

Indentation

{
indent : [ 'Tab' ],
unindent : [ 'Tab', false, true ],
toggleTabMode: [ 'M', true ],
}
JavaScript

Jump

{
jumpToLine: [ 'G', true ],
}
JavaScript

Shortcuts

{
cutLine : [ 'X', true ],
copyLine: [ 'C', true ],
moveUp : [ 'ArrowUp', true ],
moveDown: [ 'ArrowDown', true ],
}
JavaScript

Custom Shortcuts

You can define custom shortcuts in the same way. When RyuseiCode detects them, it emits the keymap:${ action } event:

const ryuseiCode = new RyuseiCode( {
keymap: {
myClearAll: [ 'D', true, true, true ],
},
} );
// ke is a native KeyboardEvent object.
ryuseiCode.on( 'keymap:myClearAll', ( e, ke ) => {
ryuseiCode.value = '';
ke.preventDefault();
ke.stopPropagation();
} );
JavaScript