/    Sign up×
Community /Pin to ProfileBookmark

Problem with keyboard control

Hi guys,

I’m working on the div class of blocks to control them using the keyboard up and down arrow buttons. I have the list of blocks where 7 of them are showing while the other blocks are hiding. I have text of blocks from block 1 to block 17. When I press on the down arrow button from block 1 to block 17, the blocks will move up using ‘rowheight’ which it looks good to go, but there is a problem. When I press on the up arrow button and the down arrow button after the block 7, the blocks supposed to stay where they are but it will move up when the yellow block is on the block 8, block 9, block 10, block 11, block 12, block 13, block 14, block 15, block 16 and block 17.

I think the problem are somewhere in this code:

[code=php] if (event.keyCode == 40)
{ //down
if(current_col < totalrowcount && current_row == 1)
{
if(current_col >= displayrowcount)
{
var currentrowtop = $(“.mainWrap div.row:first-child”).css( “margin-top”);
currentrowtop = parseInt(currentrowtop)-rowheight;
var rowtop = currentrowtop+=”px”;
$(“.mainWrap div.row:first-child”).css( “margin-top”, rowtop );
}
current_col++;
}
}[/code]

In this case, when I press on the down arrow button from block 1 to block 7 and if I press on the up arrow button, the blocks will not move up where it stays on. When I press on the down arrow button after the block 7, if I press on the up arrow button and then the down arrow button, the blocks will move up. The same things that goes for other blocks. I want the blocks to move up only when I’m after the end of the block where the blocks are hiding, e.g.: I’m on the block 7 while the other blocks after the block 7 are hiding so I can move them up. I don’t want to move the blocks up when I’m not the end of the block.

Does anyone know how I can block the blocks from move up when I’m not after the end of the block while the other blocks are hiding?

Here’s my example site if you need to take a look: [url]http://testbox.elementfx.com/blocks.php[/url]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @mark107 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...