Key Presses
Pratique testes de eventos de teclado e atalhos. Esta página é ideal para testar automação de pressionamento de teclas, validação de atalhos de teclado e captura de eventos keydown, keyup e keypress.
Sobre esta Seção
Atividades do Dia a Dia:
- Testar eventos de teclado (keydown, keyup, keypress)
- Validar atalhos de teclado (Ctrl+C, Ctrl+V, Enter, Esc, etc.)
- Praticar automação de digitação e pressionamento de teclas
- Testar combinações de teclas (Shift, Ctrl, Alt)
- Validar captura de códigos de teclas e caracteres
- Testar teclas especiais (Arrow keys, Tab, Space, etc.)
- Validar comportamento com diferentes layouts de teclado
Como Utilizar:
- Clique no campo de entrada abaixo
- Digite qualquer texto ou pressione teclas especiais
- Observe as informações exibidas sobre a tecla pressionada
- Teste diferentes teclas e combinações
- Use os
data-testidpara criar testes automatizados
Campo de Teste de Teclado
Digite ou pressione teclas no campo abaixo para ver os eventos capturados.
Pressione uma tecla para ver as informações...
Teclas de Teste Rápido:
Informações para Testes
Cenários de Teste:
- Pressionar teclas individuais e validar captura
- Testar atalhos de teclado (Ctrl+C, Ctrl+V, etc.)
- Validar teclas especiais (Enter, Esc, Tab, Arrow keys)
- Testar combinações de teclas (Shift, Ctrl, Alt)
- Validar códigos de teclas e caracteres capturados
Elementos identificáveis:
data-testid="key-input"- Campo de entradadata-testid="key-result"- Área de resultadodata-testid="btn-test-enter"- Botão testar Enterdata-testid="btn-test-esc"- Botão testar Esc
Exemplos de Teste Automatizado:
// Cypress - Testar teclas
cy.get('[data-testid="key-input"]').type('Hello{enter}')
cy.get('[data-testid="key-result"]').should('contain', 'Enter')
cy.get('[data-testid="key-input"]').clear().type('{esc}')
cy.get('[data-testid="key-result"]').should('contain', 'Escape')
cy.get('[data-testid="key-input"]').clear().type('Teste')
cy.get('[data-testid="key-result"]').should('contain', 'Teste')
// Playwright - Testar teclas
await page.getByTestId('key-input').fill('Hello')
await page.getByTestId('key-input').press('Enter')
await expect(page.getByTestId('key-result')).toContainText('Enter')
await page.getByTestId('key-input').press('Escape')
await expect(page.getByTestId('key-result')).toContainText('Escape')
await page.getByTestId('key-input').fill('Teste')
await expect(page.getByTestId('key-result')).toContainText('Teste')
// Selenium Java - Testar teclas
WebElement input = driver.findElement(By.cssSelector("[data-testid='key-input']"));
input.sendKeys("Hello");
input.sendKeys(Keys.ENTER);
WebElement result = driver.findElement(By.cssSelector("[data-testid='key-result']"));
assert result.getText().contains("Enter");
input.clear();
input.sendKeys(Keys.ESCAPE);
assert result.getText().contains("Escape");
# Capybara (Ruby) - Testar teclas
fill_in 'key-input', with: 'Hello'
find('[data-testid="key-input"]').native.send_keys(:return)
expect(find('[data-testid="key-result"]')).to have_content('Enter')
find('[data-testid="key-input"]').set('')
find('[data-testid="key-input"]').native.send_keys(:escape)
expect(find('[data-testid="key-result"]')).to have_content('Escape')
*** Test Cases ***
Testar tecla Enter
Input Text css:[data-testid="key-input"] Hello
Press Keys css:[data-testid="key-input"] RETURN
Element Should Contain css:[data-testid="key-result"] Enter
Testar tecla Escape
Press Keys css:[data-testid="key-input"] ESCAPE
Element Should Contain css:[data-testid="key-result"] Escape