{"action":"created","issue":{"url":"https://api.github.com/repos/jupyter/help/issues/71","repository_url":"https://api.github.com/repos/jupyter/help","labels_url":"https://api.github.com/repos/jupyter/help/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/jupyter/help/issues/71/comments","events_url":"https://api.github.com/repos/jupyter/help/issues/71/events","html_url":"https://github.com/jupyter/help/issues/71","id":171268213,"number":71,"title":"add keyboard short-cut within a code cell during editing","user":{"login":"ttimbers","id":6865016,"avatar_url":"https://avatars.githubusercontent.com/u/6865016?v=3","gravatar_id":"","url":"https://api.github.com/users/ttimbers","html_url":"https://github.com/ttimbers","followers_url":"https://api.github.com/users/ttimbers/followers","following_url":"https://api.github.com/users/ttimbers/following{/other_user}","gists_url":"https://api.github.com/users/ttimbers/gists{/gist_id}","starred_url":"https://api.github.com/users/ttimbers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ttimbers/subscriptions","organizations_url":"https://api.github.com/users/ttimbers/orgs","repos_url":"https://api.github.com/users/ttimbers/repos","events_url":"https://api.github.com/users/ttimbers/events{/privacy}","received_events_url":"https://api.github.com/users/ttimbers/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2016-08-15T21:38:40Z","updated_at":"2016-08-16T22:57:43Z","closed_at":null,"body":"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 '<-'. \r\n\r\nI 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:\r\n\r\n- I have to have clicked on the outside of the cell (I cannot have my cursor inside the code part of the cell)\r\n- The text shows up in the output area, not the code cell (this is where I want it to be)\r\n\r\ncurrent code:\r\n```\r\n%%javascript\r\n\r\nJupyter.keyboard_manager.command_shortcuts.add_shortcut('alt--', {\r\n    help : 'add assignment symbol',\r\n    help_index : 'zz',\r\n    handler : function (event) {\r\n        element.text('<-');\r\n        return false;\r\n    }}\r\n);\r\n```\r\n\r\nAny 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!"},"comment":{"url":"https://api.github.com/repos/jupyter/help/issues/comments/240265128","html_url":"https://github.com/jupyter/help/issues/71#issuecomment-240265128","issue_url":"https://api.github.com/repos/jupyter/help/issues/71","id":240265128,"user":{"login":"Carreau","id":335567,"avatar_url":"https://avatars.githubusercontent.com/u/335567?v=3","gravatar_id":"","url":"https://api.github.com/users/Carreau","html_url":"https://github.com/Carreau","followers_url":"https://api.github.com/users/Carreau/followers","following_url":"https://api.github.com/users/Carreau/following{/other_user}","gists_url":"https://api.github.com/users/Carreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Carreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carreau/subscriptions","organizations_url":"https://api.github.com/users/Carreau/orgs","repos_url":"https://api.github.com/users/Carreau/repos","events_url":"https://api.github.com/users/Carreau/events{/privacy}","received_events_url":"https://api.github.com/users/Carreau/received_events","type":"User","site_admin":false},"created_at":"2016-08-16T22:57:43Z","updated_at":"2016-08-16T22:57:43Z","body":"> sadly my code needs a reference to the specific cell, so it’s not that easy. the functions only get the codemirror instance as parameter, and those don’t reference the cell.\r\n\r\nUse `Jupyter.notebook.get_selected_cell()` ?\r\n\r\n> that’s awesome! and i wasn’t insinuating that it goes too slow or something!\r\n\r\nI was not trying to imply you were, just that it should move faster now, and that you should not get surprised if you see @gnestor around !\r\n"}}
{"actor":{"display_login":"Carreau"}}