Skip to content

Commit

Permalink
keydown before fill
Browse files Browse the repository at this point in the history
  • Loading branch information
kv109 committed Dec 11, 2012
1 parent a7b5ddb commit a51cf1a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions autologger.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
var infoDivId = '__AL109'+this.name;

that.addEventListener('dblclick', function(){
that.simulateKeyDown();
var value = AL.inputs.valueToPut(type, that);
that.value = value;

Expand All @@ -194,11 +195,31 @@
var valueToPut = AL.inputs.valueToPut(type, this);

if(!valueToPut.match('Set your')) {
this.simulateKeyDown();
this.value = valueToPut;
}
}
},

HTMLInputElement.prototype.simulateKeyDown = function() {
var keyboardEvent = document.createEvent("KeyboardEvent");
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";

keyboardEvent[initMethod](
"keydown", // event type : keydown, keyup, keypress
true, // bubbles
true, // cancelable
window, // viewArg: should be window
false, // ctrlKeyArg
false, // altKeyArg
false, // shiftKeyArg
false, // metaKeyArg
40, // keyCodeArg : unsigned long the virtual key code, else 0
0 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0
);
this.dispatchEvent(keyboardEvent);
},

NodeList.prototype.toArray = function() {
var htmlElements = []
for(var i=0; i<this.length; i++) {
Expand Down

0 comments on commit a51cf1a

Please sign in to comment.