AppNeta - How do I mimic keyboard commands in Selenium
search cancel

AppNeta - How do I mimic keyboard commands in Selenium


Article ID: 260238


Updated On:




In AppNeta Experience, we have a selenium script which requires us to use a keyboard command.  

How can we delete or backspace to remove text from a field in Selenium?
Or can we hit TAB to move to the next field?
Or can we submit the login using Enter instead of clicking the submit button?


The commands you are looking for is keyDown and keyUp.  These commands requires specifying the correct value.

From docs:

So as indicated above,  ENTER is \e007. 

Space is \e00D
Delete is \e017
Backspace is \e003
Escape is \e00C
Tab is \e004

When using the command, you can specify the target, or use a click command with a target preceding the keyDown. 
Use also keyUp to let go of the key command you specifed.

You may need to add a waitforElement or pause command, depending on your script and the next steps in your wokflow.


Key Code
Cancel U+E001
Help U+E002
Back space U+E003
Tab U+E004
Clear U+E005
Return1 U+E006
Enter1 U+E007
Shift U+E008
Control U+E009
Alt U+E00A
Pause U+E00B
Escape U+E00C
Key Code
Space U+E00D
Pageup U+E00E
Pagedown U+E00F
End U+E010
Home U+E011
Left arrow U+E012
Up arrow U+E013
Right arrow U+E014
Down arrow U+E015
Insert U+E016
Delete U+E017
Semicolon U+E018
Equals U+E019
Key Code
Numpad 0 U+E01A
Numpad 1 U+E01B
Numpad 2 U+E01C
Numpad 3 U+E01D
Numpad 4 U+E01E
Numpad 5 U+E01F
Numpad 6 U+E020
Numpad 7 U+E021
Numpad 8 U+E022
Numpad 9 U+E023
Key Code
Multiply U+E024
Add U+E025
Separator U+E026
Subtract U+E027
Decimal U+E028
Divide U+E029
Key Code
F1 U+E031
F2 U+E032
F3 U+E033
F4 U+E034
F5 U+E035
F6 U+E036
F7 U+E037
F8 U+E038
F9 U+E039
F10 U+E03A
F11 U+E03B
F12 U+E03C
Command/Meta U+E03D