Search code examples
schemeracketkey-bindings

DrRacket Custom Keybindings


In DrRacket IDE, I would like to change the default C-F6 shortcut for shift-focus with C-Tab.

In meta code it should be:

    #lang s-exp framework/keybinding-lang

    (keybinding "c:tab" (λ (editor evt) (send editor shift-focus)))

Unfortunately shift-focus is not part of the DrRacket API. I found a reference to it, but I am unable to covert it in a procedure to use for keybinding.


Solution

  • According to https://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html#%28part._defining-shortcuts%29, you can bind the key to an existing command as follows:

    #lang s-exp framework/keybinding-lang
    
    (define (rebind key command)
      (keybinding
       key
       (λ (ed evt)
         (send (send ed get-keymap) call-function
               command ed evt #t))))
    
    (rebind "c:tab" "shift-focus")