event.shift by itself does what you want.
If you press and hold shift and press other keys at the same time you will
always get true.
If you still wanna know if it has been released, you can use
if(e.code==16){} on keyup.
Fábio Miranda Costa
Engenheiro de Computação
http://meiocodigo.com
On Wed, Mar 4, 2009 at 5:42 AM, marlun78 <[email protected]> wrote:
>
> Hey!
>
> I'm writing a class where I'm at one point is trying to find out if
> the shift key is pressed or not. On the key-down event it woks fine,
> but on the key-up it returns false (when I release the shift key). Is
> that correct? How can I find out if it in fact was the shift-key that
> was released?
>
> $(element).addEvent('keydown', function(event){
> console.log('down', 'shift: ' + event.shift); // writes 'down,
> shift: true'
> if(event.shift) { this.shiftKeyIsDown = true; }
> });
>
> $(element).addEvent('keyup', function(event){
> console.log('up', 'shift: ' + event.shift); // writes 'up, shift:
> false'
> if(event.shift) { this.shiftKeyIsDown = false; }
> });
>
> /Martin
>