KeyboardPress

Simulate a keyboard input

This CPH method uses the SendKeys method.

The keyPress string argument needs to be enclosed in curly brackets {}.

To use key combinations such as Shift, and Alt, you can use code modifiers listed in the link below.

Full reference of all SendKeys keystroke values and modifiers.

Signature

public void KeyboardPress(string keyPress)

Parameters

keyPress
string required

The keystroke to send.

Return Type

void

Example

using System;

public class CPHInline
{
  public bool Execute()
  {
    // Examples:

    // 'W'
    CPH.KeyboardPress("{W}"); 
    // 'DOWN ARROW'
    CPH.KeyboardPress("{DOWN}"); 
    // 'SHIFT' and 'W'
    CPH.KeyboardPress("+{W}"); 
    // 'CTRL' and 'W'
    CPH.KeyboardPress("^{W}"); 
    // 'ALT' and 'W'
    CPH.KeyboardPress("%{W}"); 
    return true;
  }
}