Urgent.News

What's breaking now, across thousands of outlets.

Tech

Building a K Command Palette (and a Fake Terminal) for My Portfolio

Press ⌘K (or Ctrl+K) anywhere on my site and you get a search box that jumps to any page, case study, game, blog post or Dota 2 hero. Press ~ and you get a terminal. Neither is essential. Both are the kind of detail that makes a developer's site feel like it was made by a developer. Here's how they're built, and the few decisions that kept them simple. Logic first, UI second Both features are…

Pressing ⌘K or Ctrl+K on the site brings up a search box that can jump to a variety of pages, including case studies, games, blog posts, or Dota 2 heroes. Similarly, pressing ~ opens a terminal, although it's not a necessity. These features give the developer's site a more personal touch.

The functionality for both features relies mainly on logic, with React used sparingly. They are built using pure functions that take in lists like posts, heroes, and work, and output a flat list of objects containing information like group, label, URL, and keywords. The items are then filtered based on a user's query.

The terminal feature is built using a switch statement with a personality, where commands like help, ls projects, and play chess perform actual actions. Commands like sudo remind the user that simplicity is non-negotiable, and exit works as expected. The terminal also uses the site's dark theme tokens, ensuring it looks consistent without any out-of-place colors.

The terminal's history, tab completion, and clear command are functional, and it records anonymous usage events to track whether users are actually utilizing it. The recorded information includes the command word, unless it's something unknown, in which case it's marked as other. This way, even if someone types a sentence into the terminal, it remains within their browser.

To see these features in action, go to simplecode.ca, press ⌘K and type chess, or press ~ and type help. If you have any suggestions for additional commands, feel free to share.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Same Architecture, Different Deployment: Why Traffic Shape Beats Diagrams

Most deployment advice starts with architecture. Draw the boxes, pick the services, ship it. I believed that was the whole job until a client project showed me otherwise.

  • Traffic shape, not architecture, dictates optimal deployment strategy
  • Client's app had modest daily users but spiked during releases/holidays
  • EC2 with Auto Scaling and ALB chosen for steady loads and known spikes

More from Tuesday 27 October →