Skip to content
This repository
Browse code

Merge pull request #115 from jimevans/sendkeys_fixes

Adding support for NULL key.
  • Loading branch information...
commit 222458f416b8db09689800b2d1e5ffd83f9c51ef 2 parents 714f774 + 1380c87
Ivan De Marino authored

Showing 1 changed file with 18 additions and 14 deletions. Show diff stats Hide diff stats

  1. +18 14 src/inputs.js
32 src/inputs.js
@@ -215,22 +215,26 @@ ghostdriver.Inputs = function () {
215 215 var key = keys[i];
216 216 var actualKey = _translateKey(session, key);
217 217
218   - if (_isModifierKey(key)) {
219   - if (_isModifierKeyPressed(key)) {
220   - _keyUp(session, actualKey);
221   - } else {
222   - _keyDown(session, actualKey);
223   - }
  218 + if (key === '\uE000') {
  219 + _clearModifierKeys(session);
224 220 } else {
225   - if (_implicitShiftKeys.hasOwnProperty(actualKey)) {
226   - session.getCurrentWindow().sendEvent("keydown", _translateKey(session, "\uE008"));
227   - _pressKey(session, actualKey);
228   - session.getCurrentWindow().sendEvent("keyup", _translateKey(session, "\uE008"));
229   - } else {
230   - if ((_currentModifierKeys & _modifierKeyValues.SHIFT) && _shiftKeys.hasOwnProperty(actualKey)) {
231   - _pressKey(session, _shiftKeys[actualKey]);
  221 + if (_isModifierKey(key)) {
  222 + if (_isModifierKeyPressed(key)) {
  223 + _keyUp(session, actualKey);
232 224 } else {
  225 + _keyDown(session, actualKey);
  226 + }
  227 + } else {
  228 + if (_implicitShiftKeys.hasOwnProperty(actualKey)) {
  229 + session.getCurrentWindow().sendEvent("keydown", _translateKey(session, "\uE008"));
233 230 _pressKey(session, actualKey);
  231 + session.getCurrentWindow().sendEvent("keyup", _translateKey(session, "\uE008"));
  232 + } else {
  233 + if ((_currentModifierKeys & _modifierKeyValues.SHIFT) && _shiftKeys.hasOwnProperty(actualKey)) {
  234 + _pressKey(session, _shiftKeys[actualKey]);
  235 + } else {
  236 + _pressKey(session, actualKey);
  237 + }
234 238 }
235 239 }
236 240 }
@@ -286,7 +290,6 @@ ghostdriver.Inputs = function () {
286 290 },
287 291
288 292 _keyUp = function (session, key) {
289   - _keyEvent(session, "keyup", key);
290 293 if (key == _translateKey(session, "\uE008")) {
291 294 _updateModifierKeys(_modifierKeyValues.SHIFT, false);
292 295 } else if (key == _translateKey(session, "\uE009")) {
@@ -294,6 +297,7 @@ ghostdriver.Inputs = function () {
294 297 } else if (key == _translateKey(session, "\uE00A")) {
295 298 _updateModifierKeys(_modifierKeyValues.ALT, false);
296 299 }
  300 + _keyEvent(session, "keyup", key);
297 301 },
298 302
299 303 _mouseClick = function (session, coords) {

0 comments on commit 222458f

Please sign in to comment.
Something went wrong with that request. Please try again.