Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ZoomOut by Meta key should be disabled. #869

Closed
jekhor opened this Issue · 10 comments

4 participants

@jekhor

Pressing Meta (Win) key in Firefox 12/Debian Linux unstable makes the map zoomed out. This behaviour should be disabled, because the Meta key can be used for global keyboard shortcuts.

Code:

src/map/handler/Map.Keyboard.js

// list of e.keyCode values for particular actions
keyCodes: {
left: [37],
right: [39],
down: [40],
up: [38],
zoomIn: [187, 61, 107],
zoomOut: [189, 109, 0]
},

The Meta key has keycode 0 in FF/Linux.

@mourner mourner referenced this issue
Merged

Keyboard Handler #663

@mourner mourner was assigned
@mourner
Owner

Thanks, will be fixed.

@ericmmartinez

The 0 key code was meant to provide support for FF on Mac (specifically FF 14.1 on OS X 10.6.8). I don't have a Linux desktop to test with. I have a fix in mind for this that will (hopefully) be more cross-browser friendly but the code may become slightly less clean as it involves capturing keydown and keypress events and handling things somewhat differently.

Patch to follow.

@mourner mourner closed this in 9e89753
@mourner
Owner

@ericmmartinez Do you mean that -/_ do not fire 189/109 keycodes in FF/Mac like in all other browsers? That's quite weird...

@ericmmartinez

The submitted pull request now looks for "+" and "-" keys themselves, rather than trying to pre-map key codes to these characters in some cross-browser way. This should be more future proof if/when browsers change key codes in different releases / on different platforms / etc...

Unfortunately the arrow keys still rely on keyCodes.

@mourner
Owner

@ericmmartinez thanks! But about the the question above? Is it really necessary to rely on two ways of detecting key strokes, or is only done in case of future changes of keycodes and theoretical cross-browser benefits? I couldn't find any info about FF/Mac having problems with keyCodes compared to other modern browsers/OSes.

@ericmmartinez

It is more because Firefox likes to use 109 while other browsers use 189 as the keyCode for the minus (-) character (107 vs 187 for the plus character too). The W3 is mum as to defining keyCodes (so far as I know) and so (using Firefox as an example) keyCodes might vary between browsers. I thought it safer to switch to looking at the characters rather than the keys. A user presses a key but the user intent is reflected by the character. This change required splitting the handling to be partly in onKeyPress and partly in onKeyDown. The reasoning for this is browser quirks explained in the pull request.

@mourner
Owner

I see your point regarding chartacters vs keycodes, but coming back to original question... You said "The 0 key code was meant to provide support for FF on Mac". So why the 0 key code if 109 or 189 work in all cases? And are there any browser/OS combinations that currently fail with the existing keycode-based approach (theory aside)?

@ericmmartinez

I think 109/189 and 107/187 should work for everything that I can test with. Whether or not it will "work in all cases" is not known to me since each browser may choose to do things their own way.

Just to clarify a bit more...
107 is the keyDown key code for the plus key (shift+equals) on Firefox. Technically we should be able to remove 61 as well. 61 is the keyDown key code for the equals key (no shift). I originally included 61 in the list of zoomIn key codes because I was unsure if it would confuse people that they have to hit shift+equals in order to zoom in when they can just hit minus (no keyboard modifiers) in order to zoom out.

@mattesCZ

Hi, the minus sign doesn't work now in firefox. I think adding keyCode 173 to zoomOut should help. Thanks.

@mourner mourner reopened this
@mourner
Owner

@mattesCZ weird, thanks for the report! Will be fixed.

@mourner mourner closed this in eed2c8a
@mourner mourner referenced this issue from a commit
@mourner mourner Merge tag 'v0.5' into stable
Version 0.5

* tag 'v0.5': (319 commits)
  fix FF minus key, close #869, update changelog and build
  fix whitespace, update build
  update zoom control styles, extract general toolbar classes, fix #1209
  minor cleanup
  update changelog more
  update changelog
  update changelog
  update build
  Robust array type check for cross-frame support
  Fix jshint unhappiness (Thanks @Guiswa)
  fixed the whitespace and also removed the quotes in object keys
  Another pass on marker-icon, better grid fitting.
  update changelog
  Oops, revert accidental commit
  add Popup zoomAnimation option, fix #999
  fix a bug with FeatureGroup bindPopup not accepting options
  Update README.md
  Remove click handler with onRemove
  udpate copyright to be more precise
  fix TileLayer.brintToFront/Back on IE6-8, close #1168
  ...
7431867
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.