Configuring Key Bindings
You can update the default key bindings (keyboard shortcuts) by the keymap
option:
new RyuseiCode( { keymap: { selectAll: [ 'A', true ], }, } );
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 ] ], }
Passing null
or false
to the action disables the shortcut:
{ selectAll: false, }
Disabling specific shortcuts does not mean it prevents the native behavior, but only deactivates RyuseiCode key bindings.
Default Key Bindings
Main
{ selectAll: [ 'A', true ], }
Search
{ search : [ 'F', true ], searchNext: [ 'F3' ], searchPrev: [ 'F3', false, true ], replace : [ 'F', true, true ], }
Comment
{ lineComment : [ '/', true ], blockComment: [ '?', true, true ], }
History
{ undo: [ 'Z', true, false ], redo: [ 'Z', true, true ], }
Indentation
{ indent : [ 'Tab' ], unindent : [ 'Tab', false, true ], toggleTabMode: [ 'M', true ], }
Jump
{ jumpToLine: [ 'G', true ], }
Shortcuts
{ cutLine : [ 'X', true ], copyLine: [ 'C', true ], moveUp : [ 'ArrowUp', true ], moveDown: [ 'ArrowDown', true ], }
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(); } );