View Full Version : Adding "End" key to the default attributes passed in the EventObject

15 Aug 2011, 1:42 AM
Whenever an event is fired, by default it contains the following "ctrlKey: false or true, shiftKey: false or true" etc.

I want to be able to the "End" key to this list of defaults, but digging down into the basic event stuff in ExtJS 4 is like a maze.

Any devs got any tips on how I can add this? I just want endKey: true or false, to appear as part of the event Object returned

15 Aug 2011, 7:50 AM
I'm a little confused about why you'd want to do this.

Keys like shift and ctrl are modifier keys. This means that they can be pressed at the same time as the main key. This is not true for most keys. As such, a key press event consists of 1 main key plus a set of modifiers. In this context it makes sense that the small number of modifier keys could be represented as a set of boolean values, whereas the main key (for which there are well over 100 possible keys) are represented by a key code.

The End key is not a modifier key, it can only ever be the main key in a key press.

Given the simplicity of checking for the End key I can't really understand why you'd want to add a boolean property:

if (ev.getKey() === ev.END) {

If you want to add a method to the event object it would be pretty trivial. Ext.EventObject is a singleton so you just need to add it to the single instance:

Ext.EventObject.isEndKey = function() {
return this.getKey() === this.END;

18 Aug 2011, 7:00 AM

Thanks for your reponse, I had revisited this problem from a previous look at it and had overlooked certain issues. I wanted to be able to detect if the end key is held down while I press a navigation arrow. In the spreadsheet app I am creating I am making end key selection work, which I have now down.

The issue was that there is a key down event on the grid view, but no key up event. Therefore could not flag when the key was no longer being pressed. In the end I just introduced a key up event into the view, solving my problem and wrote the logic to set a boolean flag if the end key was press or not.