KeyEventArgs Object

Bing
 

Contains the arguments for keyboard events.

Name

Type

Description

altKey

boolean

A boolean indicating if the ALT key was pressed.

ctrlKey

boolean

A boolean indicating if the CTRL key was pressed.

eventName

string

The event that occurred.

handled

boolean

A boolean indicating whether the event is handled. If this property is set to true, the default map control behavior for the event is cancelled.

keyCode

string

The ASCII character code that identifies the keyboard key that was pressed.

originalEvent

object

The original browser event.

shiftKey

boolean

A boolean indicating if the SHIFT key was pressed.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">

         var map = null;         

         function GetMap()
         {
            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("myMap"),
                         {credentials:"Bing Maps Key"}); 

            //Add handler for the map click event.
            Microsoft.Maps.Events.addHandler(map, 'keypress', addPin);


         }

          function addPin(e) {

              if (e.keyCode == "112") {

                  // If the 'p' key is pressed, add a pushpin to the center of the 
                  //   current map view.
                  var center = map.getCenter();
                  var pin = new Microsoft.Maps.Pushpin(center);
                  map.entities.push(pin);

              }
          }

      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div><br>
      <b>Click the 'p' key to add a pushpin to the map.</b>
   </body>
</html>
Show: