The playground interface

This guide is a tour of the playground at rtcode.io/x/: the toolbar, the input and the output, the split between them, the four menus, the status indicators, titles and routes, and the templates for new code. Each part links to the guide that covers it in depth.

The screen

The playground is one page: a toolbar above a split panel that holds the input and the output, a console button and a stack of notifications.

The toolbar

A dark toolbar runs along the top. From left to right it holds:

  • the File button, the RTCode.io logo with the sync pill, which opens the File menu;
  • the title button: the title of the playground, its first route and its editors;
  • the code statistics: characters and lines of the input, the cursor and the selection;
  • the delta controls =, ↑ and ↓, shown only while a selection holds a number or a boolean;
  • on the right, the Playground button, which shows the layout and a few badges, the cast button of Remote Output, hidden until a remote session exists, the Open button ↗ and the User avatar.

A toolbar that overflows scrolls sideways with the vertical mouse wheel, and by dragging an empty part of it with the mouse. The arrow keys move the focus between its controls, and Esc outside a menu returns the focus to the input.

The input

The input is a Monaco editor, the editor of VS Code, in HTML mode with two-space indentation, LF line endings, bracket-pair colors, a minimap that stays hidden until the mouse is over it, and Emmet. Global shortcuts work while you type: the editor hands every key it does not use to the playground. F1 opens the command palette, which lists every command, and a right-click opens the context menu with the RTCode groups. See Commands.

The code statistics show the characters and lines of the input on the left, and on the right the cursor as Line:Column, or ×N with N cursors, the number of selected characters and, with more than one line selected, ×N lines. The tooltip reads Input ⏐ Selection.

While the input is not in focus, a transparent curtain covers it. The wheel still scrolls the editor, a click focuses it and removes the curtain, and a right-click opens the context menu. The sync direction follows the focus: with the focus in the input, edits flow to the output, and without it, changes in the page flow to the input. See Live sync and reloads.

With a number selected, the delta controls appear. ↑ and ↓ change the number, = edits the delta expression, and a ✱ on it marks an expression other than (x + d). The first time you select a number in a top-level playground, a tooltip shows the key once per page load, for 1.5 seconds. See Editing superpowers.

The output

The output is a frame that runs your page on an origin of its own, out.rtcode.io, apart from the editor. When the playground is embedded, or in a browser that gives its editor no origin-keyed agent cluster, such as Safari, the output uses out.rtcode.net instead. The frame is not sandboxed, and it delegates the clipboard, fullscreen, camera, microphone, geolocation, MIDI, payment, display capture, screen wake lock and encrypted media features to your page, so the page can ask for them like any other.

Open ▸ Output ▸ Tab and Popup move the output into a window of its own, always on out.rtcode.net. While an output is external, the panel shows Output in external window. and the split moves to the input. Closing the last external window reloads the playground, which brings the inline output back. Reloading or leaving the playground closes the windows it opened. See Output windows.

Viewport, zoom, color scheme, user preferences, text direction, language, font size and animation speed of the output can be changed without touching the source. See Output settings.

Notifications and the console

Notifications appear as toasts in a stack at the top right, for three seconds by default. Alt+N / ⌥+N focuses the stack, and Esc hides the focused toast.

The 📜 button at the bottom left, or at the bottom right when the output is on the left, opens the console, and a right-click opens the network panel. Badges beside it count the log, info, debug, warn and error calls, with failed assertions, and the network requests of the page and its workers. F12 toggles the console. See Console and network.

Layouts and the split

Four layouts

The input and the output sit side by side or stacked, and either one can come first. The layout is part of the link of a playground. A key that holds its default value is left out.

LayoutArrangementKeys in a link
ioInput on the left, output on the right. The default.none
oiOutput on the left, input on the right.se=oi
i/oInput on top, output below.h=1
o/iOutput on top, input below.h=1&se=oi

From code, s.layout reads and sets the layout. See Selection and layout globals.

Changing the layout

  • Alt+/ / ⌥+/ switches between side by side and stacked.
  • Alt+P / ⌥+P swaps the input and the output, and mirrors the split, so a split at 30% becomes 70%.

Both are also in Playground ▸ Swap, and on the split popover.

The split

Drag the divider to move the split, or use keys. Alt+1 / ⌥+1 to Alt+9 / ⌥+9 set 10% to 90%. Pressing the digit of the current position mirrors it. Alt+0 / ⌥+0 sets 100%, or 0% when the split is above 90%, Alt+[ / ⌥+[ and Alt+] / ⌥+] move it by 1%, or by 10% with Shift, and Alt+' / ⌥+' mirrors it. Numpad digits are refused, because they are reserved for alt codes. On macOS the editor has actions for these keys, because ⌥ and a key would otherwise type a character.

Ctrl+' / ⌘+' focuses the divider, and then its keys need no modifier. Press it again to return to the input. Ctrl+Alt+' / ⌘+⌥+' locks the split: the divider turns red on hover. The playground remembers one split position for each axis during the session, and a window resize keeps the last percentage. The position of the split is not stored in a link.

From code, s.Position reads and sets the split from 0 to 100, with a capital P.

The split popover

Hovering, focusing or clicking the divider shows a popover with the commands that belong to the split:

Position

Set the split to 0%, 10%, 50%, 90% or 100%, or step it with the arrows or the brackets.

Swap

Toggle the layout with /, or swap the panels with P.

Output settings

A button that opens the Output settings dialog.

Color Scheme

A click cycles the output between system, dark and light, and a right-click toggles dark and light. In Safari a click opens a WebKit bug report instead, and the right-click and the keys still work.

Zoom

Zoom out, zoom in, a prompt for a number, and presets from .25 to 5.

Focus

Move the focus to the input, the divider or the output.

Scroll

The keys that scroll every output from the editor.

Four menus hang from the toolbar. The File menu is also called the Code menu in the palette and the Main Menu to assistive technology, and the Playground menu carries an older name in the palette. This guide uses the names of the tooltips. On macOS, ⌃+⌥+U opens the User menu in the editor and ⌥+U elsewhere.

MenuToolbar buttonKeysPalette name
FileThe logo buttonAlt+F / ⌥+FShow Code Menu
PlaygroundThe layout buttonAlt+J / ⌥+JShow Share Menu
OpenThe ↗ buttonAlt+K / ⌥+KShow Open Menu
UserThe avatarAlt+U / ⌃+⌥+UShow User Menu
  • With a fine pointer, a menu opens when you hover its button, and closes 500 ms after the pointer leaves, if hovering opened it. A click opens it and keeps it open. Touch users tap.
  • ↓ on a focused button opens its menu. ↑ and ↓ move and wrap, Home and PageUp go to the first item, End and PageDown to the last, a letter jumps to the next item that starts with it, Enter activates and Esc closes.
  • The key of an item shows beside it, in the macOS form on Apple platforms. Tooltips appear after 200 ms.
  • Some items keep their menu open after you use them, such as the Live toggles, Delete and the Capture items.
  • Items can take modifiers. See Commands.

The File menu

The File menu holds everything that starts something: sync, new code, the edge and the agent folder.

SectionItemsNotes
SyncInput → Output with Live Sync, Once Sync and Once Load; Input ← Output with Live Sync and Once SyncEach item has a tooltip with its trigger, its update and what happens to the state. See Live sync and reloads and the sync commands.
CodeNew, Size, VersionsVersions shows only when you are signed in. See the code commands.
EdgeNetwork, Route or Routes, Deploy, Open, Delete, LoadThe Route item shows the number of routes. See the edge commands.
AgentPins, Explore, Share, UnshareOnly where FileSystemObserver exists and the playground is top level. Share and Unshare carry an auto badge. See Agent 📂 Share™.
CaptureWindow; then PiP, Image, Video, Save, Pause, Resume and Stop, each in its stateNeeds getDisplayMedia() and is hidden when embedded. Hovering the label shows a live preview. See Screen capture.

The Route item shows Alt+T as its hint on Windows and Linux, and ⌥+R on macOS. Alt+T sets the title and Alt+R sets the routes, as Keyboard shortcuts explains.

The Playground menu

The Playground menu holds what changes the arrangement and the input: swap, editing, output settings and fullscreen. Its button shows the layout.

SectionItems
SwapLayout, Panels
InputCommands; Code with Find, Replace, Copy, Clear, Paste and Edit ▸ Undo, Redo; Select with None, Line, Highlights, All, HTML and History
OutputSettings
FullscreenInput, Window, Output. Hidden where the browser has no Fullscreen API.
Last itemsTour, Reload (only when embedded), Reset, Feedback and About

Reset opens the Clear Caches page at cc.rt.ht, and Feedback opens the feedback repository on GitHub. About, Alt+Shift+/ / ⌥+⇧+/, shows the RTCode™ trademark notice, the copyright line, the version lines and the name of your browser.

The Open menu

The Open menu opens things in other windows.

ItemDoes
Playground ▸ TabOnly in an embedded playground. Opens the current state in a new top-level tab.
Output ▸ Tab, PopupOpen the output in a window of its own. Popup is hidden on touch-only devices.
Output ▸ Remote ExperimentalMirrors the output to another device. A work in progress.
Edge ▸ Route or RoutesOpens the deployed page. Hidden when embedded.

The Popup item shows Alt+B, but its key is Alt+Shift+B / ⌥+⇧+B.

The User menu

The header names RTCode.io and links to Elefunc.com, the terms and the privacy policy. Signed out, the menu offers Sign in with GitHub, Google, Microsoft or Apple, and marks the provider you used last. Signed in, it shows:

  • your account email;
  • Usage, which opens your usage page in a window named _usage;
  • Domains, a dialog that lists the subdomains and custom domains you claimed. Click a subdomain to release it, with a prompt that wants its exact name, or choose claim domain to claim another. A custom domain shows setup until it is active. See Domains and subdomains;
  • Routes, Alt+. / ⌥+., a drawer with your recent deployments, each with its time, a Copy button, a link to open it, Edit…, Versions… and its screenshot;
  • a workers meter and a storage meter, each with a tooltip, refreshed whenever the menu opens;
  • Sign out.

An action that needs an account opens this menu with a toast such as Sign in to deploy. The playground restores your session when it is top level; an embedded playground does not.

Menus that change

A menu item can be disabled or absent, depending on the state:

  • With no routes, Edge ▸ Open, Edge ▸ Load, Edge ▸ Delete, Code ▸ Versions and Open ▸ Edge ▸ Route are disabled. Code ▸ Size stays enabled.
  • In an embedded playground, the Code and Edge sections, Open ▸ Edge and the Capture section are hidden, and Open ▸ Playground ▸ Tab and Playground ▸ Reload appear. A click on the title button opens the File menu instead of the Code dialog.
  • The Agent section needs Chrome or Edge on a computer. See Browser support.

Status indicators

Small signs on the toolbar, the menus and the tab tell you what the playground is doing.

IndicatorMeaning
The sync pill on the logo button→ means Live input → output only, ← Live output → input only, ↔ both and × neither. The → arrow flashes green after an incremental sync, amber after a full load and red on a failure, and the flash clears after about 200 ms, except a failure. The pill rotates with the layout.
An F6 badge on the logo buttonThe page changed while the input had focus, or while a folder was shared, and the change was not pulled into the input. It shows only while Live output → input is on. F4, F6, Ctrl+Alt+O / ⌃+⌥+O, a full load and any pull that reaches the input clear it.
A folder on the Playground buttonAgent Folder Share is active.
A red dot or a pause icon on the Playground buttonA video is recording, or paused.
A sun or a moon on the Playground buttonThe output color scheme is forced to light or to dark.
×N on the Playground buttonThe output zoom is not 1.
The title buttonThe title, hidden when empty, and under it the first route, or Unrouted. A click on the route opens the Code dialog on Routes. A badge counts the routes when there are several, and another the editors. The tooltip lists the title, the routes, the editors and the keys. A middle-click opens the first route, and with Shift all routes.
Badges on the 📜 buttonCounts of log, info, debug, warn and error calls, and of network requests. A click opens that view.
The cast button ExperimentalRemote Output sessions exist. It shows their number.
An auto badge on Share and UnshareIt is green while Auto-Share is on, and neutral while it is off.
A last label on a sign-in providerThe provider you used last. The menu focuses it first.
The tab iconThe icon of your page, drawn at half size over the RTCode logo, or the exact icon when its link carries io:- Experimental. While a folder is shared, a capture runs or pins are picked, the logo carries three letters: share A or _, capture W, R, I, O, C or _, pins _, P or a count from 0 to 9. During a deploy or a delete the icon is a cloud for up to 65 seconds.
The tab title𝗥𝗧𝗖𝗼𝗱𝗲 • and then the first that exists of the <title> of your page, the title of the playground and its first route, or Instant Web Playground – Edit, View, Live!. A <title> with io:- Experimental is used as it is, without the prefix.

Title, routes and editors

A playground has a title, routes and editors, and you set them in the Code dialog. Open it with a click on the title button, with Alt+T / ⌥+T for the title, with Alt+R / ⌥+R for the routes, or from code with Code.edit(). An untitled playground opens it on Routes. The dialog has three fields:

Set keeps the values, and reads Deploy when a deploy opened the dialog. Cancel restores the old ones. Tab and Shift+Tab move between fields, and Enter moves to the button. A route or an editor that is a duplicate or invalid shows a toast, Duplicate: … or Invalid: ….

The browser tab shows the title of the output document first, then your title, then the first route. See Deploying to RTEdge.net for the route syntax and Code for the script interface.

New code: templates, snippets and importing

The New Code chooser

Create: New Code… opens a chooser over the playground. Run it with Ctrl+Alt+N / ⌘+⌥+N (⌃+⌘+⌥+N in the macOS editor), with File ▸ Code ▸ New, from the context menu, or by opening https://rtcode.io/x/#act=code.new. The link go.rt.ht leads to that address.

Template links open in a new tab. Hold Shift while you click or press Enter to open one in the tab you are in. Touch devices have no Shift and always get a new tab. Esc closes the chooser, and on touch devices a tap on the background does too.

Templates

The chooser lists these templates. New Project starts with a viewport and a color-scheme meta, and the cursor on the line below them. A link that ends in ? opens the source of a deployed template; see Linking to and embedding the playground.

GroupTemplateOpens
StartNew Project: start from scratchst.rt.ht
StartImport Pen: paste a CodePen URLcp.rt.ht
StartZoo.Do: vectorize APIsin.rt.ht/zoo.do/usage/?
WorkersKV Storagekv.rt.ht/?
WorkersJavaScript: import JS modules into your workersmd.rt.ht/worker?
WorkersWebAssemblywasm.rt.ht/?
WorkersStreaming: stream real-time data with Server-Sent Eventsstream.rt.ht/?
FrontendEmbed PDF: <pdf-file> and <pdf-page>pd.rt.ht
FrontendMarkdown: a zero-dependency web componentmd.rt.ht/?
FrontendClock: a timezone-aware <analog-clock>clock.rt.ht/?

Snippets

Snippet commands insert at the cursor: Alt+S / ⌥+S a style, Alt+X / ⌥+X a script, Alt+M / ⌥+M a module script and Alt+G / ⌥+G a simple worker, which also needs a single empty cursor. In the inserted text, | marks where the cursor lands and |>…<| what is selected. New Markdown (MD) and New Script Worker have no key, and are in the palette and the context menu. See Editing superpowers.

RTCode adds Emmet abbreviations Experimental to the ones the editor knows, such as z for <style>, x for <script>, w for a worker and we for an edge worker.

Importing

  • Import URL…, Ctrl+Alt+V / ⌘+⌥+V, asks for a URL, prefilled from the clipboard, and replaces the whole input as one edit that you can undo. CodePen pen URLs are fetched through cp.rt.ht, and the title of the playground becomes the title of the pen. A request that a browser blocks is retried through a fetch proxy. A response that is not a success shows its status in an alert.
  • Paste URL Content… fetches the same way and inserts the text at the cursor. The title stays.
  • Paste with Positions… pastes clipboard text in which | creates cursors and |>…<| creates selections. With the clipboard blocked it shows Clipboard blocked by browser and a prompt.

To open a CodePen pen, change codepen.io to xcodepen.io in its URL, or use rtcode.io/<user>/pen/<id>. Both lead to cdpn.rt.ht, which opens the pen in the playground. The link https://xcodepen.io/ alone opens the Import URL prompt.

Closing, reloading and embedding

Closing or reloading the tab asks you to confirm while a folder is shared, while the URL state is not yet written, and while a deploy or a delete is running. Ctrl+R / ⌘+R anywhere in the playground first writes the URL state, so a reload keeps your session.

Other sites can embed the playground in a frame. An embedded playground has the menus listed above, no Agent section and no restored sign-in session, and it ignores the act key of its link. When its link has no source, it loads a starter page with a clock, logos and a counter. See Linking to and embedding the playground.

See also