Friday, 15 February 2013

javascript - How do I detect the "enter" key and "shift" key at the same time to insert a line break -


I am trying to create a note system. Whatever you write in the form, it is put in a div. When users hit , they submit notes, however, when I hit Shift + + , then this Creates a point where they are typing (like Skype). Here's my code:

  $ ('# inputpnote'). Keypress (function (event) {var keycode = (event.keyCode? Event.keyCode: event.which); if (keycode = ('& lt; br & gt;');} and if (keycode == '13' ) {Var $ pnote = document.getElementById (= '13 '& amp; amp; amp; event.shiftKey) "InputPlan"); value; if ($ pnote.length> gt; {$ ("# pnotes- Listing "). The app (" 
  • "+ $ Pnote +"
    "); $ ('# Inputpnote'). Val ('');}}});
  • #inputpnote is a form where a user enters his note and # pnotes-list is a place where notes are added Being my service Thank you in advance!

    I think you have to set two global variables, log in for 1 ShitftKeyPress and 1 and Then you will need a keydown and a keypot to set those values ​​and then check to see that both of them are correct, because your argument is saying, when a key is pressed, execute this code Please, if you press a key and then press another key, only that which is the function Programmed called time.

    Edit: Example code that should be visible to it:

      Var haspressedShift = false; Var haspressedEnter = false; $ ('#InputPnote') keydown (function (event) {if shiftkey} {hasPressedShift = true;} if (enterKey) {hasPressedEnter = true;}}); $ ('#InputPnote') keyboard (task (event) {if (shifting) {hasPressedShift = false}; if (enter that) {hasPressedEnter = false;}}); $ ('#InputPnote') Keypress (function) {if (hash shampoo & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp;  

    It was quick fake, but it looks like that


    No comments:

    Post a Comment