[AngularJS] Key-up / key-down directives - RFC

982 views
Skip to first unread message

Pawel Kozlowski

unread,
Nov 29, 2012, 1:25:24 PM11/29/12
to ang...@googlegroups.com
Hi!

So, here is this long-opened
https://github.com/angular/angular.js/issues/1035 and a fresh PR:
https://github.com/angular/angular.js/pull/1622 (thnx Mark!)

I wonder what is your opinion on this, functionally speaking?

Would simply reacting to a key event and figuring out keys pressed
from the $event would be enough for you?
Or maybe you would like to specify key codes as a directive attribute?
Or maybe you don't care at all as a directive is easy to write and is
not needed in core?

WDYT?

Cheers,
Pawel

--
Question? Send a fiddle
(http://jsfiddle.net/pkozlowski_opensource/Q2NpJ/) or a plunk
(http://plnkr.co/)
Need help with jsFiddle? Check this:
http://pkozlowskios.wordpress.com/2012/08/12/using-jsfiddle-with-angularjs/

Looking for UI widget library for AngularJS? Here you go:
http://angular-ui.github.com/

Michael Bielski

unread,
Nov 29, 2012, 2:57:30 PM11/29/12
to ang...@googlegroups.com
I would like to see this as a directive that is included in the core. Also, I think I'd like to be able to specify what keycode I am looking for as an optional attribute. If it is present when called, then yes, look for that keycode, otherwise just capture the event as a whole.

digger69

unread,
Nov 29, 2012, 9:28:58 PM11/29/12
to ang...@googlegroups.com
IMHO, I wouldn't hold this PR for enhancing for ability to specify keycode since could get sticky if we start considering key modifiers (ctrl, alt, shift).

digger69

unread,
Dec 5, 2012, 10:16:34 AM12/5/12
to ang...@googlegroups.com
Today I found that angular-ui project has a Keypress directive

It allows both binding just on any keypress - or keycode-specific, including aliasing; e.g. instead of binding to "13" you can bind to "enter".

It seems pretty complete. Not sure what the best go-forward is though. I think this does fit better in the ng namespace.

ProLoser

unread,
Dec 13, 2012, 2:14:32 PM12/13/12
to ang...@googlegroups.com
Yeah... our UI implementation is pretty thorough, I would think it would be worthwhile to compare the two before moving forward with merging the PR. I realize ours sort of opens new floodgates (such as people asking for EVERY key to be aliased or having multiple non-modifier keys pressed simultaneously) but having keydown, keyup and keypress alone is fairly critical. You can also have multiple key combinations trigger the same function/callback/code

ui-keypress= { 'shift-enter ctrl-enter alt-enter' : ' goHome() ` }

Michael Bielski

unread,
Dec 13, 2012, 4:41:22 PM12/13/12
to ang...@googlegroups.com
Damn... I need to look at the UI more... had no idea that was there!

So, if I read ProLoser's post correctly, a combination like "shift-ctrl-enter" is not currently possible in AngularUI?

ProLoser

unread,
Dec 13, 2012, 5:12:53 PM12/13/12
to ang...@googlegroups.com
I never said that. That combination is supported, just go try it out!

Michael Bielski

unread,
Dec 13, 2012, 5:50:52 PM12/13/12
to ang...@googlegroups.com
Ok, so I was incorrect in my interpretation. Obviously my caffination level is off. I'll certainly check it out! Thanks!
Reply all
Reply to author
Forward
0 new messages