Results 1 to 2 of 2

Thread: switch enter to shift+enter

  1. #1
    Join Date
    Jul 2012

    switch enter to shift+enter

    hi every body
    sorry for my bad english
    i have a contenteditable P tag
    i want to change enter event on keydown to shift+enter
    but when i change e.shiftkey=true take error

    can you help me ?

  2. #2
    Join Date
    Feb 2003
    Michigan, USA
    Are you getting a JavaScript error? If so, please post it.

    Otherwise, you might try attaching a mousedown handler to the <p> tag's parent node, and when the key code of the event is the shift key, set a variable to true on the page.

    Next, you'll need a keypress event on the same DOM node. When the keypress event fires, and the key code is 13 (which I believe is the keycode for the ENTER key) and the shift key flag is true, then you know that the SHIFT + ENTER combo was used.

    Lastly, you'll need a keyup event on the same DOM node to set the shift key variable to false.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center