> ## Documentation Index
> Fetch the complete documentation index at: https://docs.testdriver.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Pressing Keys Test Example

> Example test demonstrating keyboard shortcuts and key combinations for browser navigation.

## Demo Test Run

Watch this test execute in a real sandbox environment:

<iframe src="https://console-test.testdriver.ai/replay/6a0524baef91e2fc9cb2048c?share=mVp7oFBwDMzBbsD8MfUg&embed=true" width="100%" height="390" style={{ border: "1px solid #333", borderRadius: "8px" }} allow="fullscreen" />

## Source Code

```javascript title="press-keys.test.mjs" {17,24,36} theme={null}
/**
 * TestDriver SDK - Press Keys Test (Vitest)
 * Converted from: testdriver/acceptance/press-keys.yaml
 */

import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";

describe("Press Keys Test", () => {
  it("should create tabs and navigate using keyboard shortcuts", async (context) => {
    const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
    await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });

    const signInButton = await testdriver.find(
      "Sign In, black button below the password field",
    );
    await signInButton.click();

    // Open new tab
    await testdriver.pressKeys(["ctrl", "t"]);

    // Poll for "Learn more" to appear
    let imagesLink = await testdriver.find("Images", {timeout: 5000});

    expect(imagesLink.found()).toBeTruthy();

    // Open DevTools
    await testdriver.pressKeys(["ctrl", "shift", "i"]);

    // Poll for "Elements" to appear
    let elements = await testdriver.find("Elements", {timeout: 5000});
    expect(elements.found()).toBeTruthy();

    // Open another tab and navigate
    await testdriver.pressKeys(["ctrl", "t"]);
    await testdriver.type("google.com");
    await testdriver.pressKeys(["enter"]);

    // Assert Google appears
    const result = await testdriver.assert("google appears");
    expect(result).toBeTruthy();
  });
});
```

## Running This Example

```bash theme={null}
# Clone the TestDriver repository
git clone https://github.com/testdriverai/testdriverai

# Install dependencies
cd testdriverai
npm install

# Run this specific example
npx vitest run examples/press-keys.test.mjs
```

<Note>
  Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
</Note>
