js_lis 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/VirtualKeyboard.js +17 -2
  2. package/package.json +1 -1
@@ -256,9 +256,24 @@ export class VirtualKeyboard {
256
256
  await this.insertText("\t");
257
257
  break;
258
258
 
259
- case "Enter":
259
+ case 'Enter':
260
260
  if (this.currentInput.tagName === "TEXTAREA") {
261
- await this.insertText("\n");
261
+ const start = this.currentInput.selectionStart;
262
+ const end = this.currentInput.selectionEnd;
263
+ const value = this.currentInput.value;
264
+ this.currentInput.value = value.slice(0, start) + "\n" + value.slice(end);
265
+ this.currentInput.setSelectionRange(start + 1, start + 1);
266
+ } else if (this.currentInput.tagName === "INPUT" || this.currentInput.type === "password" || this.currentInput.type === "text") {
267
+ if (this.currentInput.form) {
268
+ const submitButton = this.currentInput.form.querySelector('input[type="submit"], button[type="submit"], button[type="button"], button[onclick]');
269
+ if (submitButton) {
270
+ submitButton.click();
271
+ } else {
272
+ this.currentInput.form.submit();
273
+ }
274
+ } else {
275
+ this.currentInput.value += '\n';
276
+ }
262
277
  }
263
278
  break;
264
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_lis",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"