User Guide
ckcode allows you to run R and Python code right on the webpage. It's like a Jupyter notebook, but without the notebook. This is a guide for learners who are using ckcode to learn R or Python.
Notes for those using keyboard navigation:
- The ckcode editor is accessible via keyboard navigation, but when you are in the editor the Tab key will not move you to the next element, it will instead indent the text. To use tab to navigate out of the editor, press the escape key first, then tab next.
- The editor has a few keyboard shortcuts of its own, which are listed at the bottom of this page. While in the editor, these shortcuts will take precedence other hotkeys you may have configured in your browser. These shortcuts are not configurable, but they will only be active when a ckcode editor is focused.
Here's a basic cell:
%%% prompt
# editor
The area at the top marked # editor
is where you can type in code. When you click the Run button, that code will be run. Try typing 1 + 1
on a new line and then click Run. You should see an output box appear below the buttons that has the number 2
. After every Run, the output will always be shown at the bottom of the code cell. If you click Reset the output will be cleared and the editor text will be reset to where it was when you started.
When a code cell has a Submit button, that means that there is a solution for cell, and that your code will be tested against the solution. See if you can figure out how to solve the code cell below:
%%% prompt
# write code that outputs the number 3
%%% test
ex() %>% check_output_expr("3")
When you click the Run button on this cell, the code is run but not tested or submitted. However, when you click Submit the code is tested against a solution and tests to see if it is correct. Then you will get some feedback based on your answer. The feedback is shown in the blue box above the output. Try entering 1 + 1
and submitting it, and then 1 + 2
.
It "remembers"
When you click Run or Submit, the cell will remember your response for next time. Try running some new code here, then refresh the page and you'll see your code was remembered. If you click Reset the code will go back to the original prompt.
%%% prompt
# change me and run!
Hotkeys
If you prefer using a keyboard over the mouse, hotkeys are provided for the Run and Submit buttons (and one to move your browser focus back to the editor after a run).
General
- When in a code cell, the tab key (
tab
) will indent the code. To usetab
to navigate to the next element, press the escape key (esc
) first, thentab
next.
Mac
Action | Hotkey |
---|---|
Run | ⌘ + Enter |
Submit | Shift + ⌘ + Enter |
Focus editor | ⌘ + e |
Interrupt | ⌘ + i |
Insert: <- |
Option + - |
Insert: |> |
Shift + ⌘ + m |
Windows / Linux
Action | Hotkey |
---|---|
Run | Ctrl + Enter |
Submit | Shift + Ctrl + Enter |
Focus editor | Ctrl + e |
Interrupt | Ctrl + i |
Insert: <- |
Alt + - |
Insert: |> |
Shift + Ctrl + m |