Firefox : There is no such field called inputType in keydown event object












0















I have an input event and a keydown event bound to a textbox in angular. In keydown event function I'm recieving an input object as the object representing the event in firefox. At the same time, I'm receiving an InputEvent object for the same event in chrome. I'm using the inputType field in the InputEvent object in chrome to identify if it is insertText, deleteContentBackward or deleteContentForward event as given below.



switch(event.inputType) {
case 'insertText':
//do something
break;
case 'deleteContentBackward':
//do something
break;
case 'deleteContentForward':
//do something
break;
}


The problem is there is no such field called inputType in the event object generated by firefox.



Event object in Chrome (71.0.3578.98)



InputEvent {
bubbles: true,
cancelBubble: false,
cancelable: false,
composed: true,
currentTarget: null,
data: null,
dataTransfer: null,
defaultPrevented: true,
detail: 0,
eventPhase: 0,
**inputType: "deleteContentBackward"**,
isComposing: false,
isTrusted: true,
path: (15) [input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched, div.col-md-9.search-input-container, div.col-12.no-padding.search.custom-search-box, div.row.input-group.col-lg-6.col-md-7.col-sm-9.col-xs-12, div.search-section.col-12, app-search-header, div.container, section#homeBanner.intro, app-header, app-root, div.wrapper, body.is-search-open, html.no-js, document, Window],
returnValue: false,
sourceCapabilities: null,
srcElement: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
target: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
timeStamp: 2484875.1999999997,
type: "input",
view: null,
which: 0
}


Given below is the same event object in firefox (65.0b7)



input{
bubbles: true,
​cancelBubble: false,
​cancelable: false,
​composed: true,
​currentTarget: null,
​defaultPrevented: false,
​detail: 0,
​eventPhase: 0,
​explicitOriginalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
​isComposing: false,
​isTrusted: true,
​layerX: 0,
​layerY: 0,
​originalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
​pageX: 0,
​pageY: 0,
​rangeOffset: 0,
​rangeParent: null,
​returnValue: true,
​srcElement: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">​
target: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
​timeStamp: 283997,
**​type: "input"**, // For insert and delete events this field won't change
​view: null,
​which: 0
}









share|improve this question



























    0















    I have an input event and a keydown event bound to a textbox in angular. In keydown event function I'm recieving an input object as the object representing the event in firefox. At the same time, I'm receiving an InputEvent object for the same event in chrome. I'm using the inputType field in the InputEvent object in chrome to identify if it is insertText, deleteContentBackward or deleteContentForward event as given below.



    switch(event.inputType) {
    case 'insertText':
    //do something
    break;
    case 'deleteContentBackward':
    //do something
    break;
    case 'deleteContentForward':
    //do something
    break;
    }


    The problem is there is no such field called inputType in the event object generated by firefox.



    Event object in Chrome (71.0.3578.98)



    InputEvent {
    bubbles: true,
    cancelBubble: false,
    cancelable: false,
    composed: true,
    currentTarget: null,
    data: null,
    dataTransfer: null,
    defaultPrevented: true,
    detail: 0,
    eventPhase: 0,
    **inputType: "deleteContentBackward"**,
    isComposing: false,
    isTrusted: true,
    path: (15) [input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched, div.col-md-9.search-input-container, div.col-12.no-padding.search.custom-search-box, div.row.input-group.col-lg-6.col-md-7.col-sm-9.col-xs-12, div.search-section.col-12, app-search-header, div.container, section#homeBanner.intro, app-header, app-root, div.wrapper, body.is-search-open, html.no-js, document, Window],
    returnValue: false,
    sourceCapabilities: null,
    srcElement: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
    target: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
    timeStamp: 2484875.1999999997,
    type: "input",
    view: null,
    which: 0
    }


    Given below is the same event object in firefox (65.0b7)



    input{
    bubbles: true,
    ​cancelBubble: false,
    ​cancelable: false,
    ​composed: true,
    ​currentTarget: null,
    ​defaultPrevented: false,
    ​detail: 0,
    ​eventPhase: 0,
    ​explicitOriginalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
    ​isComposing: false,
    ​isTrusted: true,
    ​layerX: 0,
    ​layerY: 0,
    ​originalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
    ​pageX: 0,
    ​pageY: 0,
    ​rangeOffset: 0,
    ​rangeParent: null,
    ​returnValue: true,
    ​srcElement: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">​
    target: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
    ​timeStamp: 283997,
    **​type: "input"**, // For insert and delete events this field won't change
    ​view: null,
    ​which: 0
    }









    share|improve this question

























      0












      0








      0








      I have an input event and a keydown event bound to a textbox in angular. In keydown event function I'm recieving an input object as the object representing the event in firefox. At the same time, I'm receiving an InputEvent object for the same event in chrome. I'm using the inputType field in the InputEvent object in chrome to identify if it is insertText, deleteContentBackward or deleteContentForward event as given below.



      switch(event.inputType) {
      case 'insertText':
      //do something
      break;
      case 'deleteContentBackward':
      //do something
      break;
      case 'deleteContentForward':
      //do something
      break;
      }


      The problem is there is no such field called inputType in the event object generated by firefox.



      Event object in Chrome (71.0.3578.98)



      InputEvent {
      bubbles: true,
      cancelBubble: false,
      cancelable: false,
      composed: true,
      currentTarget: null,
      data: null,
      dataTransfer: null,
      defaultPrevented: true,
      detail: 0,
      eventPhase: 0,
      **inputType: "deleteContentBackward"**,
      isComposing: false,
      isTrusted: true,
      path: (15) [input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched, div.col-md-9.search-input-container, div.col-12.no-padding.search.custom-search-box, div.row.input-group.col-lg-6.col-md-7.col-sm-9.col-xs-12, div.search-section.col-12, app-search-header, div.container, section#homeBanner.intro, app-header, app-root, div.wrapper, body.is-search-open, html.no-js, document, Window],
      returnValue: false,
      sourceCapabilities: null,
      srcElement: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
      target: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
      timeStamp: 2484875.1999999997,
      type: "input",
      view: null,
      which: 0
      }


      Given below is the same event object in firefox (65.0b7)



      input{
      bubbles: true,
      ​cancelBubble: false,
      ​cancelable: false,
      ​composed: true,
      ​currentTarget: null,
      ​defaultPrevented: false,
      ​detail: 0,
      ​eventPhase: 0,
      ​explicitOriginalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
      ​isComposing: false,
      ​isTrusted: true,
      ​layerX: 0,
      ​layerY: 0,
      ​originalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
      ​pageX: 0,
      ​pageY: 0,
      ​rangeOffset: 0,
      ​rangeParent: null,
      ​returnValue: true,
      ​srcElement: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">​
      target: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
      ​timeStamp: 283997,
      **​type: "input"**, // For insert and delete events this field won't change
      ​view: null,
      ​which: 0
      }









      share|improve this question














      I have an input event and a keydown event bound to a textbox in angular. In keydown event function I'm recieving an input object as the object representing the event in firefox. At the same time, I'm receiving an InputEvent object for the same event in chrome. I'm using the inputType field in the InputEvent object in chrome to identify if it is insertText, deleteContentBackward or deleteContentForward event as given below.



      switch(event.inputType) {
      case 'insertText':
      //do something
      break;
      case 'deleteContentBackward':
      //do something
      break;
      case 'deleteContentForward':
      //do something
      break;
      }


      The problem is there is no such field called inputType in the event object generated by firefox.



      Event object in Chrome (71.0.3578.98)



      InputEvent {
      bubbles: true,
      cancelBubble: false,
      cancelable: false,
      composed: true,
      currentTarget: null,
      data: null,
      dataTransfer: null,
      defaultPrevented: true,
      detail: 0,
      eventPhase: 0,
      **inputType: "deleteContentBackward"**,
      isComposing: false,
      isTrusted: true,
      path: (15) [input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched, div.col-md-9.search-input-container, div.col-12.no-padding.search.custom-search-box, div.row.input-group.col-lg-6.col-md-7.col-sm-9.col-xs-12, div.search-section.col-12, app-search-header, div.container, section#homeBanner.intro, app-header, app-root, div.wrapper, body.is-search-open, html.no-js, document, Window],
      returnValue: false,
      sourceCapabilities: null,
      srcElement: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
      target: input#search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
      timeStamp: 2484875.1999999997,
      type: "input",
      view: null,
      which: 0
      }


      Given below is the same event object in firefox (65.0b7)



      input{
      bubbles: true,
      ​cancelBubble: false,
      ​cancelable: false,
      ​composed: true,
      ​currentTarget: null,
      ​defaultPrevented: false,
      ​detail: 0,
      ​eventPhase: 0,
      ​explicitOriginalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
      ​isComposing: false,
      ​isTrusted: true,
      ​layerX: 0,
      ​layerY: 0,
      ​originalTarget: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
      ​pageX: 0,
      ​pageY: 0,
      ​rangeOffset: 0,
      ​rangeParent: null,
      ​returnValue: true,
      ​srcElement: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">​
      target: <input id="search-input" class="form-control custom-inpu…lid ng-dirty ng-touched" _ngcontent-c10="" type="text" ng-reflect-model="a" placeholder="What are you looking for ?">,
      ​timeStamp: 283997,
      **​type: "input"**, // For insert and delete events this field won't change
      ​view: null,
      ​which: 0
      }






      javascript angular firefox cross-browser






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 8:04









      Ammar Ibnu AmeerdeenAmmar Ibnu Ameerdeen

      4601316




      4601316
























          1 Answer
          1






          active

          oldest

          votes


















          1














          It is possible to solve this problem in this way, in a jquery environment.



          On Angular, I solved the problem this way.



          isBackSpace = false;

          onKeyDown(event:KeyboardEvent){
          this.isBackSpace = event.which === 8;
          /// rest of the method
          }

          onSearchChange(event){
          if (event.inputType === 'deleteContentForward' || event.inputType === 'deleteContentBackward' || this.IsBackSpace) {
          // delete event handling code.
          } else {
          // insert event handling code.
          }
          this.isBackSpace = false;
          }





          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54018429%2ffirefox-there-is-no-such-field-called-inputtype-in-keydown-event-object%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            It is possible to solve this problem in this way, in a jquery environment.



            On Angular, I solved the problem this way.



            isBackSpace = false;

            onKeyDown(event:KeyboardEvent){
            this.isBackSpace = event.which === 8;
            /// rest of the method
            }

            onSearchChange(event){
            if (event.inputType === 'deleteContentForward' || event.inputType === 'deleteContentBackward' || this.IsBackSpace) {
            // delete event handling code.
            } else {
            // insert event handling code.
            }
            this.isBackSpace = false;
            }





            share|improve this answer






























              1














              It is possible to solve this problem in this way, in a jquery environment.



              On Angular, I solved the problem this way.



              isBackSpace = false;

              onKeyDown(event:KeyboardEvent){
              this.isBackSpace = event.which === 8;
              /// rest of the method
              }

              onSearchChange(event){
              if (event.inputType === 'deleteContentForward' || event.inputType === 'deleteContentBackward' || this.IsBackSpace) {
              // delete event handling code.
              } else {
              // insert event handling code.
              }
              this.isBackSpace = false;
              }





              share|improve this answer




























                1












                1








                1







                It is possible to solve this problem in this way, in a jquery environment.



                On Angular, I solved the problem this way.



                isBackSpace = false;

                onKeyDown(event:KeyboardEvent){
                this.isBackSpace = event.which === 8;
                /// rest of the method
                }

                onSearchChange(event){
                if (event.inputType === 'deleteContentForward' || event.inputType === 'deleteContentBackward' || this.IsBackSpace) {
                // delete event handling code.
                } else {
                // insert event handling code.
                }
                this.isBackSpace = false;
                }





                share|improve this answer















                It is possible to solve this problem in this way, in a jquery environment.



                On Angular, I solved the problem this way.



                isBackSpace = false;

                onKeyDown(event:KeyboardEvent){
                this.isBackSpace = event.which === 8;
                /// rest of the method
                }

                onSearchChange(event){
                if (event.inputType === 'deleteContentForward' || event.inputType === 'deleteContentBackward' || this.IsBackSpace) {
                // delete event handling code.
                } else {
                // insert event handling code.
                }
                this.isBackSpace = false;
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 3 at 8:58

























                answered Jan 3 at 8:52









                Ammar Ibnu AmeerdeenAmmar Ibnu Ameerdeen

                4601316




                4601316
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54018429%2ffirefox-there-is-no-such-field-called-inputtype-in-keydown-event-object%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas