You can simply use event.shift in combination with event.key, see the docs:
http://mootools.net/docs/core/Types/Event

element.addEvent('keydown', function(event){
    if (event.shift && event.key == 'enter') alert('hi');
});

If you use Element.Event.Pseudos from more you can use, see:
http://mootools.net/docs/more/Element/Element.Event.Pseudos.Keys

element.addEvent('keydown:keys(shift+enter)', function(){
    alert('hi');
});




On Thu, Mar 3, 2011 at 6:14 PM, Stewart Mckinney <[email protected]>wrote:

> You should check for e.shift && e.keycode == '13', technically, if you want
> to use your approach.
>
> Right now your checking to see if your key is "enter" and "not shift".
> That's not the same as checking to see if shift
> is depressed when hitting enter.
>
> The other thing you have to keep in mind is that it won't capture someone
> hitting "shift while holding enter", which is
> pretty uncommon, but it could happen.
>
> I believe Keyboard from More handles that case, however.
>
> Also, speaking from an input/interface POV, be aware that shift and enter
> behave differently.
> Shift will not repeat itself if the user holds it down (most of the time?)
> - Enter will.
>
> On Thu, Mar 3, 2011 at 11:15 AM, Andrea Dessì <[email protected]> wrote:
>
>> Hi,
>>
>> can I suggest you to use the More.Keyboard class? :)
>>
>> try it here:
>> http://jsfiddle.net/NKjoep/8PwFE/
>>
>> --
>> Andrea
>>
>> On Thu, Mar 3, 2011 at 16:50, hamburger <[email protected]> wrote:
>>
>>> Hello,
>>> i would like to check my form for shift-enter
>>> shift-enter should be allowed. On enter the form should submit.
>>>
>>>
>>> $('chatText').addEvent('keydown',function(event){
>>>    if ((event.key=='enter') && (event.key!=16)) {
>>>                        alert("ENTER");
>>>        }
>>>    });
>>>
>>> This code do not take care of shift and allerts on enter and on shift-
>>> enter.
>>> whats wrong.
>>> thanks for any help in advance
>>>
>>>
>>
>

Reply via email to