Override OOTB keyUp and keyDown functionalities

Hi ,

Can some one guide me how can I override the OOTB key up and key down functionalities . Currently in the OOTB navigation works fine and after we have navigated to desired selection when we press enter it displays the corresponding tree item details . But what I have been trying to do is the details should be displayed on up and down navigation without pressing enter .

[code]tree.attachEvent(‘onKeyPress’, function(key, event){
if((tree._selected).length > 0){
var xKey = 88, vKey = 86, cKey = 67, delKey = 46, escKey = 27,enterKey = 13,i, treeId, selectedNodeId, selectedNodeIds=[];
if(event.ctrlKey && (key==cKey)) {
pubsub.publish(‘copyTree’ + index);
}
else if(event.ctrlKey && (key==vKey)){
pubsub.publish(‘pasteTree’ + index);
}
else if(event.ctrlKey && (key==xKey)){
pubsub.publish(‘cutTree’ + index);
}
else if(key==delKey){
pubsub.publish(‘deleteTree’ + index, ‘delete’);
}else if(key==escKey){
tree.clearCut();
cutCopyManager.clear();
}else if(key==enterKey){
if(tree._selected && tree._selected.length>0){
treeId = (tree._selected)[0].id;
showProductDetails(treeId);
}
}else if(key==40 || key==38){
if(tree._selected && tree._selected.length>0){
treeId = (tree._selected)[0].id;
showProductDetails(treeId);
}
return true;
}

            else{
                 return true;
            }
        }
    });[/code]

I have added the else if block of (key==40 || key==38) and everything else was there before itself.

With this the problem I am facing is , It is displaying the previous element selection for up and down navigation and not the current selection .

Can some one guide me where I am going wrong ??

Thanks

Hi,

You can try to move “up”/“down” logic into onSelect event handler. In this case you will get correct selection state:

tree.attachEvent(“onSelect”, showProductDetails);