0

I am attempting to bind arrow keys for use as accessibility navigation listeners. I have found a few articles talking about how to bind the functions using jquery, the most useful being this:Binding arrow keys in JS/jQuery.

That being said, I cannot find any way to actually create a global set of arrow key functions that will allow my users to use arrow keys site wide. is this possible using jquery? or is it based completely on using classes in places where I would use arrow keys, such as drop menus?

I am currently using asp.net MVC and razor view to generate my pages.

Community
  • 1
  • 1
Joshua
  • 311
  • 1
  • 3
  • 19
  • You can't set the key bindings for an entire site at once, but if you simply put your binding function into an external ".js" file and make sure that each page in your site links to it, you will have that functionality in every page. – Scott Marcus Jan 03 '17 at 21:00
  • @ScottMarcus can this be done using asp.net MVC? using the site.js? – Joshua Jan 03 '17 at 21:01
  • Not sure, that's a different question. You should edit your question to reflect that you are using ASP.NET MVC (remember to add those tags to the question as well). – Scott Marcus Jan 03 '17 at 21:03
  • @ScottMarcus Noted and edited, I realized I had left that out at the beginning and corrected my mistake, but thank you for pointing that out. – Joshua Jan 03 '17 at 21:03

1 Answers1

1

In the MVC you can do it with layout.cshtml file (mostly inside of the /Views/Shared folder)

You can find more information about MVC layout files in that link

As @ScottMarcus said in the comments, create a .js file which include your arrow keys binding functions.

After that, add the < script src='...js' / > link into layout.cshtml file header section.

If you want to use this layout.cshtml file for all actions, create a file named "_ViewStart.cshtml" in the Views folder, put this code into the _viewstart.cshtml file;

@{
Layout = "~/Views/Shared/_Layout.cshtml";
}

If you don't want to use layout in any action, add that line inside of the view of that action;

@{
    layout=null;
}

There are more different options to do this... But I think thats enough for you :)

Serhat MERCAN
  • 1,078
  • 3
  • 14
  • 31
  • 1
    Thank you very much, it makes sense that It could be done through the layout file. I will try this out. – Joshua Jan 03 '17 at 21:23