Skip to content
This repository was archived by the owner on Mar 26, 2019. It is now read-only.
This repository was archived by the owner on Mar 26, 2019. It is now read-only.

add keyboard short-cut within a code cell during editing #71

@ttimbers

Description

@ttimbers

I want to be able to add a keyboard short-cut within a code cell during editing. Specifically, I want to recreate RStudio's 'alt--' short-cut that results in an in-place text insertion of '<-'.

I have been playing around with using %% javascript magic to do this. With the code below I can manage to get <- output to the output area, but there are two problem with this:

  • I have to have clicked on the outside of the cell (I cannot have my cursor inside the code part of the cell)
  • The text shows up in the output area, not the code cell (this is where I want it to be)

current code:

%%javascript

Jupyter.keyboard_manager.command_shortcuts.add_shortcut('alt--', {
    help : 'add assignment symbol',
    help_index : 'zz',
    handler : function (event) {
        element.text('<-');
        return false;
    }}
);

Any help to point me in the direction of getting this working to further develop this feature would be greatly appreciated (the plan is to add the final working code to custom.js so it works in all my notebooks). Additionally, such a feature would be desired by any R user using Jupyter. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions