Simple neon / pixel styled calculator you can open by just double‑clicking index.html. No build tools, no frameworks.
Goal: look cool, stay readable, be easy to explain in an interview.
https://retro-calculator.ankankun.me/
Desktop view:
Mobile view:
- Basic math: + − × ÷
- Extra: percent %, change sign (±), clear (AC)
- Decimal numbers
- Keyboard support (0‑9 . + - * / Enter = Esc)
- Shows the full operation when you press =
- Live IST clock at the bottom
- Mobile friendly (shrinks buttons on very narrow screens)
State variables in script.js:
current -> string shown on the green main display (starts '0')
previous -> stored number after you pick an operator
operator -> '+', '-', '*', '/' (null when none selected)
justCalculated -> true right after '=' so next number replaces result
Flow:
- Press numbers -> they append to
current(unless we just finished a calc). - Press an operator -> move
currentintoprevious, store operator, resetcurrentto '0'. - Press more numbers -> build second number.
- Press '=' -> compute with
previous+operator+current, show result, clearprevious+operator, flagjustCalculated. - Chain operations: if you press another operator instead of '=', we quickly run
equals()then continue. - Percent = divide
currentby 100. Sign = toggle leading-. - Divide by zero -> shows
ERR(very basic error handling).
Formatting helper: trimResult() keeps numbers from overflowing by shortening long outputs or using scientific notation for huge values.
| Key | Action |
|---|---|
| 0‑9 | Digits |
| . | Decimal point |
| + - * / | Operators |
| Enter or = | Equals |
| Esc | AC (clear) |
- Only simple color variables kept (easier to tweak). Removed spacing & font size CSS variables to look less “tool generated”.
- Pixel font: Google Fonts
Press Start 2P. - Scanline effect: a pseudo element with a repeating linear gradient.
- Neon glow: stacked box‑shadows around buttons.
- Layout: plain CSS Grid for buttons (
repeat(4, 1fr)), no frameworks.
- Container width capped at 384px (classic small handheld size feel).
- At < 360px screen width: smaller font + smaller button padding.
- Memory keys (M+, M-, MR, MC)
- Backspace (delete last digit)
- History panel
- Better error handling (flash screen, etc.)
- Limit significant digits more intelligently
- Theme toggle (bright vs dark neon)
Updated every second. Uses toLocaleString with timeZone:'Asia/Kolkata' so it shows IST regardless of the user’s local machine timezone.
Enjoy hacking it. Tweak colors, break it, fix it, learn it. Retro vibe unlocked. 😎

