Reputation: 11
1.When i use keyboard up arrow it should highlight a move to up row and if i press down arrow the high light should move to down row
2.If i use uparrow or down arrow along with ctrl ,i should be able to multi select.
Here i have wrote code if i keep pressing up arrow it is continuing selecting and down arrow it is deselecting but i want do as what i mentioned above [http://jsfiddle.net/hKZqS/2/]
Upvotes: 1
Views: 369
Reputation: 30135
switch(e.which)
{
// user presses the "a" key
case 38: if(!e.ctrlKey)
$('tr').removeClass('ui-selected');
$('tr#'+(clickid-1)).attr('class', 'ui-selected');
clickid = clickid-1;
break;
// user presses the "s" key
case 40: if(!e.ctrlKey)
$('tr').removeClass('ui-selected');
$('tr#'+(clickid+1)).attr('class', 'ui-selected');
clickid = clickid+1;
break;
}
you'll also have to check if clickid is > 0 and < tr count.
http://jsfiddle.net/hKZqS/8/
Upvotes: 1