Commit 7bd376d6355524899dc6bc059f2796cfafd2c4ab

Authored by Jose Pinto
1 parent 32f00bd612
Exists in master and in 1 other branch develop

Agrego boton enter

... ... @@ -34,26 +34,29 @@
34 34 "pump": "^3.0.x"
35 35 },
36 36 "devDependencies": {
37   - "angular": "^1.7.5",
  37 + "angular": "1.7.5",
38 38 "angular-route": "^1.7.5",
39   - "angular-sanitize": "^1.7.5",
40   - "bootstrap": "^4.1.3",
41   - "font-awesome": "^4.7.0",
42   - "gulp": "^3.9.1",
43   - "gulp-angular-templatecache": "^2.2.2",
44   - "gulp-clean": "^0.4.0",
45   - "gulp-concat": "^2.6.1",
46   - "gulp-connect": "^5.6.1",
47   - "gulp-htmlmin": "^5.0.1",
48   - "gulp-jshint": "^2.1.0",
49   - "gulp-rename": "^1.4.0",
50   - "gulp-replace": "^1.0.0",
51   - "gulp-sass": "^4.0.2",
52   - "gulp-uglify-es": "^1.0.4",
53   - "jasmine-core": "^3.2.1",
54   - "jquery": "^3.3.1",
55   - "jshint": "^2.9.6",
56   - "pre-commit": "^1.2.2",
57   - "pump": "^3.0.0"
  39 + "angular-sanitize": "1.7.5",
  40 + "bootstrap": "4.1.3",
  41 + "font-awesome": "4.7.0",
  42 + "gulp": "3.9.1",
  43 + "gulp-angular-templatecache": "2.2.5",
  44 + "gulp-clean": "0.4.0",
  45 + "gulp-concat": "2.6.1",
  46 + "gulp-connect": "5.6.1",
  47 + "gulp-htmlmin": "5.0.1",
  48 + "gulp-jshint": "2.1.0",
  49 + "gulp-rename": "1.4.0",
  50 + "gulp-replace": "1.0.0",
  51 + "gulp-sass": "4.0.2",
  52 + "gulp-uglify-es": "1.0.4",
  53 + "jasmine-core": "3.3.0",
  54 + "jquery": "3.3.1",
  55 + "jshint": "2.9.6",
  56 + "pre-commit": "1.2.2",
  57 + "pump": "3.0.0"
  58 + },
  59 + "dependencies": {
  60 + "angular-on-screen-keyboard": "git+https://github.com/ericf97/angular-on-screen-keyboard.git"
58 61 }
59 62 }
src/js/angular-on-screen-keyboard-directive.js
... ... @@ -84,6 +84,9 @@ angular.module('onScreenKeyboard', ['ngSanitize'])
84 84 } else if (key.type === 'shift') {
85 85 ctrl.isUpperCase = !ctrl.isUpperCase;
86 86 return;
  87 + } else if (key.type === 'enter'){
  88 + ctrl.pressEnterKey();
  89 + return;
87 90 }
88 91  
89 92 var htmlKeyVal = angular.element(event.target || event.srcElement).text();
... ... @@ -171,6 +174,42 @@ angular.module('onScreenKeyboard', ['ngSanitize'])
171 174 }
172 175 };
173 176  
  177 + ctrl.pressEnterKey = function () {
  178 +
  179 + $timeout(function () {
  180 + if (angular.element(':focus').length > 0) {
  181 +
  182 + let el = angular.element(':focus')[0],
  183 + down = new KeyboardEvent('keydown',
  184 + {
  185 + which: 13,
  186 + keyCode: 13,
  187 + bubbles: true,
  188 + cancelable: true,
  189 + }),
  190 + press = new KeyboardEvent('keypress',
  191 + {
  192 + which: 13,
  193 + keyCode: 13,
  194 + bubbles: true,
  195 + cancelable: true,
  196 + }),
  197 + up = new KeyboardEvent('keyup',
  198 + {
  199 + which: 13,
  200 + keyCode: 13,
  201 + bubbles: true,
  202 + cancelable: true,
  203 + });
  204 +
  205 + el.dispatchEvent(down);
  206 + el.dispatchEvent(press);
  207 + el.dispatchEvent(up);
  208 + }
  209 + });
  210 +
  211 + };
  212 +
174 213 var focusin = function(event) {
175 214 var e = event.target || event.srcElement;
176 215  
src/js/controller.js
... ... @@ -11,7 +11,8 @@ angular.module('focaTeclado')
11 11 ],
12 12 [
13 13 {type: 'margin', colspan: 1},
14   - {type: 'button', colspan: 6, text: ' '}
  14 + {type: 'button', colspan: 6, text: ' '},
  15 + {type: 'enter', colspan: 3, text: 'Enter'}
15 16 ]
16 17 ];
17 18