Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-2025-04-14· OpenAIHugging Face LMArena Human Preference 140K

Write a HTML/JS/CSS prototype of an on-screen keyboard imitating a classic mobile phone…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Googlegemma-3-27b-it’s answer.
  1. User

    Write a HTML/JS/CSS prototype of an on-screen keyboard imitating a classic mobile phone keys.

    Keyboard should have two parts, depending on the mode they may be joined. If screen width is bigger than screen height, we span full height + fixed width and the left part is on the left, screen on the center and right part is on the right. If height bigger than width, two parts joined on the bottom, spanning full width and a fixed height.

    Keys should have dark background and light text. Keys should be as big (with two exceptions).

    Left part: 3x4 grid with keys: 1, 2, 3 4, 5, 6 7, 8, 9 *, 0, #

    Right part: 3x3 grid with keys: "L", Up, "R" Left, OK, Right Esc, Down, [Maximize]

    Up, Down, Left, Right should be arrows. Keys Esc and Maximixe(symbolized) should be purposefully smaller.

  2. Assistant

    Certainly! Below is a responsive HTML/JS/CSS prototype for a classic mobile phone on-screen keyboard, as you described.

    Features:

    • Responsive layout: Adapts to landscape (side-by-side) and portrait (joined at bottom) modes.
    • Key arrangement: Left (3x4) and Right (3x3) grids, with special sizing for Esc and Maximize.
    • Dark theme: Dark backgrounds, light text.
    • Arrows: Unicode arrows for navigation.
    • Maximize: Uses a Unicode symbol (⛶).
    • Screen: Centered between the two parts in landscape, above in portrait.

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Classic Mobile On-Screen Keyboard</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <style>
        :root {
          --key-bg: #222;
          --key-fg: #fff;
          --key-size: 64px;
          --key-gap: 8px;
          --key-radius: 12px;
          --key-font: 1.5rem;
          --key-small-font: 1rem;
          --key-small-size: 40px;
          --screen-bg: #111;
          --screen-fg: #0f0;
          --screen-radius: 12px;
          --screen-padding: 16px;
          --keyboard-width: calc(var(--key-size) * 3 + var(--key-gap) * 2);
          --keyboard-height: calc(var(--key-size) * 4 + var(--key-gap) * 3);
          --right-width: calc(var(--key-size) * 3 + var(--key-gap) * 2);
          --right-height: calc(var(--key-size) * 3 + var(--key-gap) * 2);
          --bottom-keyboard-height: calc(var(--key-size) * 4 + var(--key-gap) * 3);
        }
    
        body {
          background: #181818;
          margin: 0;
          min-height: 100vh;
          color: #fff;
          font-family: 'Segoe UI', Arial, sans-serif;
          display: flex;
          justify-content: center;
          align-items: center;
          height: 100vh;
          box-sizing: border-box;
        }
    
        .container {
          display: flex;
          flex-direction: row;
          align-items: center;
          justify-content: center;
          width: 100vw;
          height: 100vh;
          transition: flex-direction 0.3s;
        }
    
        .keyboard-left, .keyboard-right {
          display: grid;
          background: #181818;
          border-radius: 16px;
          padding: var(--key-gap);
          gap: var(--key-gap);
          box-sizing: border-box;
          user-select: none;
        }
    
        .keyboard-left {
          grid-template-columns: repeat(3, var(--key-size));
          grid-template-rows: repeat(4, var(--key-size));
          width: var(--keyboard-width);
          height: var(--keyboard-height);
          margin: 0 16px;
        }
    
        .keyboard-right {
          grid-template-columns: repeat(3, var(--key-size));
          grid-template-rows: repeat(3, var(--key-size));
          width: var(--right-width);
          height: var(--right-height);
          margin: 0 16px;
        }
    
        .screen {
          background: var(--screen-bg);
          color: var(--screen-fg);
          border-radius: var(--screen-radius);
          min-width: 220px;
          min-height: 60px;
          padding: var(--screen-padding);
          margin: 0 16px;
          text-align: center;
          font-size: 1.5rem;
          box-shadow: 0 0 8px #000a;
          display: flex;
          align-items: center;
          justify-content: center;
          flex: 1 1 auto;
          max-width: 400px;
          max-height: 120px;
        }
    
        .key {
          background: var(--key-bg);
          color: var(--key-fg);
          border: none;
          border-radius: var(--key-radius);
          font-size: var(--key-font);
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          transition: background 0.1s, box-shadow 0.1s;
          box-shadow: 0 2px 6px #0006;
          outline: none;
          user-select: none;
          width: var(--key-size);
          height: var(--key-size);
          font-family: inherit;
          position: relative;
        }
    
        .key:active {
          background: #333;
          box-shadow: 0 1px 2px #0008;
        }
    
        /* Small keys */
        .key.small {
          font-size: var(--key-small-font);
          width: var(--key-small-size);
          height: var(--key-small-size);
          padding: 0;
        }
    
        /* Responsive: Portrait mode */
        @media (max-aspect-ratio: 1/1) {
          .container {
            flex-direction: column;
            justify-content: flex-end;
            align-items: center;
          }
          .screen {
            margin: 0 0 16px 0;
            max-width: 90vw;
          }
          .keyboard-bottom {
            display: flex;
            flex-direction: row;
            width: 100vw;
            justify-content: center;
            align-items: flex-end;
            background: #181818;
            padding-bottom: 8px;
          }
          .keyboard-left, .keyboard-right {
            margin: 0 8px;
          }
          .keyboard-left {
            grid-template-columns: repeat(3, minmax(0, 1fr));
            grid-template-rows: repeat(4, minmax(0, 1fr));
            width: unset;
            height: unset;
            flex: 1 1 0;
            min-width: 0;
            min-height: 0;
          }
          .keyboard-right {
            grid-template-columns: repeat(3, minmax(0, 1fr));
            grid-template-rows: repeat(3, minmax(0, 1fr));
            width: unset;
            height: unset;
            flex: 1 1 0;
            min-width: 0;
            min-height: 0;
          }
        }
      </style>
    </head>
    <body>
      <div class="container" id="container">
        <div class="keyboard-left" id="keyboard-left">
          <button class="key" data-key="1">1</button>
          <button class="key" data-key="2">2</button>
          <button class="key" data-key="3">3</button>
          <button class="key" data-key="4">4</button>
          <button class="key" data-key="5">5</button>
          <button class="key" data-key="6">6</button>
          <button class="key" data-key="7">7</button>
          <button class="key" data-key="8">8</button>
          <button class="key" data-key="9">9</button>
          <button class="key" data-key="*">*</button>
          <button class="key" data-key="0">0</button>
          <button class="key" data-key="#">#</button>
        </div>
        <div class="screen" id="screen">Ready</div>
        <div class="keyboard-right" id="keyboard-right">
          <button class="key" data-key="L">L</button>
          <button class="key" data-key="ArrowUp">&#8593;</button>
          <button class="key" data-key="R">R</button>
          <button class="key" data-key="ArrowLeft">&#8592;</button>
          <button class="key" data-key="OK">OK</button>
          <button class="key" data-key="ArrowRight">&#8594;</button>
          <button class="key small" data-key="Esc">Esc</button>
          <button class="key" data-key="ArrowDown">&#8595;</button>
          <button class="key small" data-key="Maximize">&#x26F6;</button>
        </div>
      </div>
      <!-- For portrait mode, we move the keyboards into a bottom bar -->
      <div class="keyboard-bottom" id="keyboard-bottom" style="display:none;">
        <div class="keyboard-left" id="keyboard-left-bottom"></div>
        <div class="keyboard-right" id="keyboard-right-bottom"></div>
      </div>
      <script>
        // Helper: clone keyboard for bottom bar
        function cloneKeyboard(id) {
          const orig = document.getElementById(id);
          const clone = orig.cloneNode(true);
          // Remove duplicate IDs
          clone.id = id + '-bottom';
          // Remove event listeners if any
          return clone;
        }
    
        // Responsive layout switcher
        function updateLayout() {
          const container = document.getElementById('container');
          const kbBottom = document.getElementById('keyboard-bottom');
          const left = document.getElementById('keyboard-left');
          const right = document.getElementById('keyboard-right');
          const leftBottom = document.getElementById('keyboard-left-bottom');
          const rightBottom = document.getElementById('keyboard-right-bottom');
          const screen = document.getElementById('screen');
          if (window.innerWidth > window.innerHeight) {
            // Landscape: side by side
            container.style.display = 'flex';
            kbBottom.style.display = 'none';
            left.style.display = '';
            right.style.display = '';
            screen.style.display = '';
          } else {
            // Portrait: bottom bar
            container.style.display = 'flex';
            left.style.display = 'none';
            right.style.display = 'none';
            screen.style.display = '';
            kbBottom.style.display = 'flex';
            // Move keys to bottom bar
            if (leftBottom.children.length === 0) {
              leftBottom.innerHTML = left.innerHTML;
            }
            if (rightBottom.children.length === 0) {
              rightBottom.innerHTML = right.innerHTML;
            }
          }
        }
    
        window.addEventListener('resize', updateLayout);
        window.addEventListener('DOMContentLoaded', () => {
          updateLayout();
    
          // Key click handler
          function handleKeyClick(e) {
            if (!e.target.classList.contains('key')) return;
            const key = e.target.getAttribute('data-key');
            const screen = document.getElementById('screen');
            if (key === 'Maximize') {
              // Simulate maximize: toggle full screen
              if (!document.fullscreenElement) {
                document.documentElement.requestFullscreen();
              } else {
                document.exitFullscreen();
              }
              screen.textContent = 'Maximize';
            } else if (key === 'Esc') {
              screen.textContent = 'Esc';
            } else {
              screen.textContent = key;
            }
          }
    
          // Attach event listeners to all keypads
          document.getElementById('keyboard-left').addEventListener('click', handleKeyClick);
          document.getElementById('keyboard-right').addEventListener('click', handleKeyClick);
          document.getElementById('keyboard-left-bottom').addEventListener('click', handleKeyClick);
          document.getElementById('keyboard-right-bottom').addEventListener('click', handleKeyClick);
        });
      </script>
    </body>
    </html>
    

    How it works:

    • Landscape: Left keypad, screen, right keypad are side by side.
    • Portrait: Both keypads are joined at the bottom, screen is above.
    • Keys: All keys are large except Esc and Maximize, which are smaller.
    • Arrows: Use Unicode arrows.
    • Maximize: Uses ⛶ (U+26F6) as the maximize symbol.
    • Screen: Shows the last key pressed.

    Try resizing the window to see the layout adapt!


    Let me know if you need further customization or features!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.