Firing EventListener inside Controller methodDynamically binding to a controller method in LightningCalling a component method from another component: Lightning aura:event not firingCall another method from a method in same Lightning controllerhow to call controller method from lightning actionaura:valueChange not firing on attributeLightning - JS controller invoking its own method - failureLightning Component JS controller call one method from other method without helperDynamic Aura:Id inside Aura:IterationVariable add on a Javascript controller inside -> component.find(' variable ') markuptoLowerCase method not working inside a filter method

How can I get an unreasonable manager to approve time off?

Why was this person allowed to become Grand Maester?

Ability To Change Root User Password (Vulnerability?)

Teaching a class likely meant to inflate the GPA of student athletes

How to safely destroy (a large quantity of) valid checks?

How come the nude protesters were not arrested?

What aircraft was used as Air Force One for the flight between Southampton and Shannon?

I have a problematic assistant manager, but I can't fire him

sed + add word before string only if not exists

Overlapping String-Blocks

Bb13b9 confusion

Moving points closer to polyline using ModelBuilder?

Check if three arrays contains the same element

With Ubuntu 18.04, how can I have a hot corner that locks the computer?

How to hide rifle during medieval town entrance inspection?

How to handle (one's own) self-harm scars (on the arm), in a work environment?

Is it possible to fly backward if you have a 'really strong' headwind?

60s or 70s novel about Empire of Man making 1st contact with 1st discovered alien race

Non-aqueous eyes?

Extreme flexible working hours: how to get to know people and activities?

Is it legal for a bar bouncer to confiscate a fake ID

Why does Sin[b-a] simplify to -Sin[a-b]?

Is it safe to change the harddrive power feature so that it never turns off?

A map of non-pathological topology?



Firing EventListener inside Controller method


Dynamically binding to a controller method in LightningCalling a component method from another component: Lightning aura:event not firingCall another method from a method in same Lightning controllerhow to call controller method from lightning actionaura:valueChange not firing on attributeLightning - JS controller invoking its own method - failureLightning Component JS controller call one method from other method without helperDynamic Aura:Id inside Aura:IterationVariable add on a Javascript controller inside -> component.find(' variable ') markuptoLowerCase method not working inside a filter method






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm trying to implement something that I would do in plain JavaScript and get it to work in Lightning. I want to detect a keyup action on an input field, so I have my component wrapped within a span like this:



<span onkeyup="!c.keyCheck">
<lightning:input aura:id="pwInput" type="password" label="Password" />
</span>


And my Controller method:



keyCheck : function(event) 
// If "caps lock" is pressed, display the warning text
if (event.getModifierState("CapsLock"))
console.log("Caps lock on");
else
console.log("Caps lock off");




This isn't firing. If this were vanilla JavaScript I'd have the EventListener set in the JS like this (which works fine in plain JS):



var input = document.getElementById("pwInput");

input.addEventListener("keyup", function(event)
// If "caps lock" is pressed, display the warning text
if (event.getModifierState("CapsLock"))
console.log("Caps lock on");
else
console.log("Caps lock off");

);


But I thought that's what adding onkeyup="!c.keyCheck" in the component was doing. Do you have any suggestions?










share|improve this question




























    2















    I'm trying to implement something that I would do in plain JavaScript and get it to work in Lightning. I want to detect a keyup action on an input field, so I have my component wrapped within a span like this:



    <span onkeyup="!c.keyCheck">
    <lightning:input aura:id="pwInput" type="password" label="Password" />
    </span>


    And my Controller method:



    keyCheck : function(event) 
    // If "caps lock" is pressed, display the warning text
    if (event.getModifierState("CapsLock"))
    console.log("Caps lock on");
    else
    console.log("Caps lock off");




    This isn't firing. If this were vanilla JavaScript I'd have the EventListener set in the JS like this (which works fine in plain JS):



    var input = document.getElementById("pwInput");

    input.addEventListener("keyup", function(event)
    // If "caps lock" is pressed, display the warning text
    if (event.getModifierState("CapsLock"))
    console.log("Caps lock on");
    else
    console.log("Caps lock off");

    );


    But I thought that's what adding onkeyup="!c.keyCheck" in the component was doing. Do you have any suggestions?










    share|improve this question
























      2












      2








      2








      I'm trying to implement something that I would do in plain JavaScript and get it to work in Lightning. I want to detect a keyup action on an input field, so I have my component wrapped within a span like this:



      <span onkeyup="!c.keyCheck">
      <lightning:input aura:id="pwInput" type="password" label="Password" />
      </span>


      And my Controller method:



      keyCheck : function(event) 
      // If "caps lock" is pressed, display the warning text
      if (event.getModifierState("CapsLock"))
      console.log("Caps lock on");
      else
      console.log("Caps lock off");




      This isn't firing. If this were vanilla JavaScript I'd have the EventListener set in the JS like this (which works fine in plain JS):



      var input = document.getElementById("pwInput");

      input.addEventListener("keyup", function(event)
      // If "caps lock" is pressed, display the warning text
      if (event.getModifierState("CapsLock"))
      console.log("Caps lock on");
      else
      console.log("Caps lock off");

      );


      But I thought that's what adding onkeyup="!c.keyCheck" in the component was doing. Do you have any suggestions?










      share|improve this question














      I'm trying to implement something that I would do in plain JavaScript and get it to work in Lightning. I want to detect a keyup action on an input field, so I have my component wrapped within a span like this:



      <span onkeyup="!c.keyCheck">
      <lightning:input aura:id="pwInput" type="password" label="Password" />
      </span>


      And my Controller method:



      keyCheck : function(event) 
      // If "caps lock" is pressed, display the warning text
      if (event.getModifierState("CapsLock"))
      console.log("Caps lock on");
      else
      console.log("Caps lock off");




      This isn't firing. If this were vanilla JavaScript I'd have the EventListener set in the JS like this (which works fine in plain JS):



      var input = document.getElementById("pwInput");

      input.addEventListener("keyup", function(event)
      // If "caps lock" is pressed, display the warning text
      if (event.getModifierState("CapsLock"))
      console.log("Caps lock on");
      else
      console.log("Caps lock off");

      );


      But I thought that's what adding onkeyup="!c.keyCheck" in the component was doing. Do you have any suggestions?







      lightning-aura-components lightning javascript






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      Matt SmithMatt Smith

      235110




      235110




















          1 Answer
          1






          active

          oldest

          votes


















          3














          Controller methods always have three parameters: component, event, helper, in that order. What's confused you is that you've named the first parameter "event". This is actually the component itself. This difference is the main change between vanilla JavaScript and Aura components.



          You need to use the second parameter:



          keyCheck: function(component, event) 
          if(event.key === 'CapsLock')
          console.log('Caps Lock pressed');
          else
          console.log('Caps Lock was not pressed');







          share|improve this answer























          • i agree with this,but why event.getModifierState() gives error like Uncaught TypeError: Illegal invocation because of locker service?

            – sdandamud1
            8 hours ago












          • @sfdcfox - thank you! I appreciate the help.

            – Matt Smith
            8 hours ago











          • @sdandamud1 - I don't know why that happens. I'm using event.getModifierState in this instance because event.keyCode is deprecated and not recommended now.

            – Matt Smith
            8 hours ago











          • so you get value for this `event.getModifierState()' ?

            – sdandamud1
            8 hours ago











          • @sdandamud1 yes. At least in my scratch org. Hopefully I don't get Locker issues moving it to dev.

            – Matt Smith
            7 hours ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "459"
          ;
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fsalesforce.stackexchange.com%2fquestions%2f265061%2ffiring-eventlistener-inside-controller-method%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









          3














          Controller methods always have three parameters: component, event, helper, in that order. What's confused you is that you've named the first parameter "event". This is actually the component itself. This difference is the main change between vanilla JavaScript and Aura components.



          You need to use the second parameter:



          keyCheck: function(component, event) 
          if(event.key === 'CapsLock')
          console.log('Caps Lock pressed');
          else
          console.log('Caps Lock was not pressed');







          share|improve this answer























          • i agree with this,but why event.getModifierState() gives error like Uncaught TypeError: Illegal invocation because of locker service?

            – sdandamud1
            8 hours ago












          • @sfdcfox - thank you! I appreciate the help.

            – Matt Smith
            8 hours ago











          • @sdandamud1 - I don't know why that happens. I'm using event.getModifierState in this instance because event.keyCode is deprecated and not recommended now.

            – Matt Smith
            8 hours ago











          • so you get value for this `event.getModifierState()' ?

            – sdandamud1
            8 hours ago











          • @sdandamud1 yes. At least in my scratch org. Hopefully I don't get Locker issues moving it to dev.

            – Matt Smith
            7 hours ago















          3














          Controller methods always have three parameters: component, event, helper, in that order. What's confused you is that you've named the first parameter "event". This is actually the component itself. This difference is the main change between vanilla JavaScript and Aura components.



          You need to use the second parameter:



          keyCheck: function(component, event) 
          if(event.key === 'CapsLock')
          console.log('Caps Lock pressed');
          else
          console.log('Caps Lock was not pressed');







          share|improve this answer























          • i agree with this,but why event.getModifierState() gives error like Uncaught TypeError: Illegal invocation because of locker service?

            – sdandamud1
            8 hours ago












          • @sfdcfox - thank you! I appreciate the help.

            – Matt Smith
            8 hours ago











          • @sdandamud1 - I don't know why that happens. I'm using event.getModifierState in this instance because event.keyCode is deprecated and not recommended now.

            – Matt Smith
            8 hours ago











          • so you get value for this `event.getModifierState()' ?

            – sdandamud1
            8 hours ago











          • @sdandamud1 yes. At least in my scratch org. Hopefully I don't get Locker issues moving it to dev.

            – Matt Smith
            7 hours ago













          3












          3








          3







          Controller methods always have three parameters: component, event, helper, in that order. What's confused you is that you've named the first parameter "event". This is actually the component itself. This difference is the main change between vanilla JavaScript and Aura components.



          You need to use the second parameter:



          keyCheck: function(component, event) 
          if(event.key === 'CapsLock')
          console.log('Caps Lock pressed');
          else
          console.log('Caps Lock was not pressed');







          share|improve this answer













          Controller methods always have three parameters: component, event, helper, in that order. What's confused you is that you've named the first parameter "event". This is actually the component itself. This difference is the main change between vanilla JavaScript and Aura components.



          You need to use the second parameter:



          keyCheck: function(component, event) 
          if(event.key === 'CapsLock')
          console.log('Caps Lock pressed');
          else
          console.log('Caps Lock was not pressed');








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 8 hours ago









          sfdcfoxsfdcfox

          273k14221472




          273k14221472












          • i agree with this,but why event.getModifierState() gives error like Uncaught TypeError: Illegal invocation because of locker service?

            – sdandamud1
            8 hours ago












          • @sfdcfox - thank you! I appreciate the help.

            – Matt Smith
            8 hours ago











          • @sdandamud1 - I don't know why that happens. I'm using event.getModifierState in this instance because event.keyCode is deprecated and not recommended now.

            – Matt Smith
            8 hours ago











          • so you get value for this `event.getModifierState()' ?

            – sdandamud1
            8 hours ago











          • @sdandamud1 yes. At least in my scratch org. Hopefully I don't get Locker issues moving it to dev.

            – Matt Smith
            7 hours ago

















          • i agree with this,but why event.getModifierState() gives error like Uncaught TypeError: Illegal invocation because of locker service?

            – sdandamud1
            8 hours ago












          • @sfdcfox - thank you! I appreciate the help.

            – Matt Smith
            8 hours ago











          • @sdandamud1 - I don't know why that happens. I'm using event.getModifierState in this instance because event.keyCode is deprecated and not recommended now.

            – Matt Smith
            8 hours ago











          • so you get value for this `event.getModifierState()' ?

            – sdandamud1
            8 hours ago











          • @sdandamud1 yes. At least in my scratch org. Hopefully I don't get Locker issues moving it to dev.

            – Matt Smith
            7 hours ago
















          i agree with this,but why event.getModifierState() gives error like Uncaught TypeError: Illegal invocation because of locker service?

          – sdandamud1
          8 hours ago






          i agree with this,but why event.getModifierState() gives error like Uncaught TypeError: Illegal invocation because of locker service?

          – sdandamud1
          8 hours ago














          @sfdcfox - thank you! I appreciate the help.

          – Matt Smith
          8 hours ago





          @sfdcfox - thank you! I appreciate the help.

          – Matt Smith
          8 hours ago













          @sdandamud1 - I don't know why that happens. I'm using event.getModifierState in this instance because event.keyCode is deprecated and not recommended now.

          – Matt Smith
          8 hours ago





          @sdandamud1 - I don't know why that happens. I'm using event.getModifierState in this instance because event.keyCode is deprecated and not recommended now.

          – Matt Smith
          8 hours ago













          so you get value for this `event.getModifierState()' ?

          – sdandamud1
          8 hours ago





          so you get value for this `event.getModifierState()' ?

          – sdandamud1
          8 hours ago













          @sdandamud1 yes. At least in my scratch org. Hopefully I don't get Locker issues moving it to dev.

          – Matt Smith
          7 hours ago





          @sdandamud1 yes. At least in my scratch org. Hopefully I don't get Locker issues moving it to dev.

          – Matt Smith
          7 hours ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • 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%2fsalesforce.stackexchange.com%2fquestions%2f265061%2ffiring-eventlistener-inside-controller-method%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

          Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

          Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

          199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單